E
E
Emptyform2017-03-01 08:25:18
JavaScript
Emptyform, 2017-03-01 08:25:18

How to execute "passport.authenticate()" without redirects on completion (koa-passport)?

Hey!
I have a small SPA training project with Angular 2a frontend and a RESTful backend in NodeJS / Коа.
I want to tie authorization with koa-passport (local strategy).
Here is the code that is executed when the user logs out:

function*() {
    yield passport.authenticate('local', {
        successRedirect: '/',
        failureRedirect: '/'
    });
};

I copied this from somewhere in the documentation. The code works great, but I don't want it to redid on success or error.
If the second parameter is removed from the function call passport.authenticate()or just an empty object is passed there, an error occurs.
I just want to get the user object in the bodyresponse, and in case of an error - false in the same place in body.
How can I do it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question