Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEAN.JS integration #33

Open
vko-online opened this issue May 28, 2015 · 6 comments
Open

MEAN.JS integration #33

vko-online opened this issue May 28, 2015 · 6 comments

Comments

@vko-online
Copy link

Please can you provide example of integration.

strategies/bearer.js (new file)

 exports.signin = function(req, res, next){
    passport.authenticate('bearer', {session: false}, function(err, user, info){
        if(err || !user) {
            res.status(400).send(info);
        } else {
            // Remove sensitive data before login
            user.password = undefined;
            user.salt = undefined;
            req.login(user, function(err){
                if(err) {
                    res.status(400).send(err);
                } else {
                    res.json(user);
                }
            });
        }
    })(req, res, next);
};

Added token field to user model

Added middleware in router

app.route('/games').get(passport.authenticate('bearer', { session: false }), games.list)

Dunno what else i must do, any ideas?

@kumavis
Copy link

kumavis commented May 30, 2015

there is an example included in the repo

@vko-online
Copy link
Author

Yes, thanks, but somehow i cannot use it in MEAN.JS stack, when user registers, it's ok, then it can sign-in, but when he signs-out and sign-ins again, the password hashes do not match

@kumavis
Copy link

kumavis commented Jun 1, 2015

sounds unrelated to this module - it doesnt use a password or hash, just an api token

@mk-pmb
Copy link

mk-pmb commented Jun 1, 2015

Maybe the bearer token was confused with a password hash. You probably get a new bearer token each time you authenticate. It's similar to a session ID.

@vko-online
Copy link
Author

There is a good sample, https://github.com/castlewhitehall/meanjs-with-token-auth
Did anyone tried to patch existing project with that token-auth?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants