fix user local signin
This commit is contained in:
@ -36,6 +36,28 @@ module.exports = function(app) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
User.afterRemote('login', function(ctx, accessToken) {
|
||||||
|
var res = ctx.res;
|
||||||
|
var req = ctx.req;
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
signed: !!req.signedCookies,
|
||||||
|
maxAge: 1000 * accessToken.ttl
|
||||||
|
};
|
||||||
|
if (accessToken && accessToken.id) {
|
||||||
|
res.cookie('access_token', accessToken.id, config);
|
||||||
|
res.cookie('userId', accessToken.userId, config);
|
||||||
|
}
|
||||||
|
res.redirect('/');
|
||||||
|
});
|
||||||
|
|
||||||
|
User.afterRemote('logout', function(ctx, result, next) {
|
||||||
|
var res = ctx.result;
|
||||||
|
res.clearCookie('access_token');
|
||||||
|
res.clearCookie('userId');
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
User.doesExist = function doesExist(username, email, cb) {
|
User.doesExist = function doesExist(username, email, cb) {
|
||||||
debug('checking existence');
|
debug('checking existence');
|
||||||
var where = {};
|
var where = {};
|
||||||
|
@ -8,7 +8,8 @@ module.exports = {
|
|||||||
passwordField: 'password',
|
passwordField: 'password',
|
||||||
authPath: '/auth/local',
|
authPath: '/auth/local',
|
||||||
successRedirect: successRedirect,
|
successRedirect: successRedirect,
|
||||||
failureRedirect: failureRedirect,
|
failureRedirect: '/email-signin',
|
||||||
|
session: true,
|
||||||
failureFlash: true
|
failureFlash: true
|
||||||
},
|
},
|
||||||
'facebook-login': {
|
'facebook-login': {
|
||||||
|
@ -2,7 +2,7 @@ extends ../layout
|
|||||||
block content
|
block content
|
||||||
.jumbotron.text-center(ng-controller="emailSignInController")
|
.jumbotron.text-center(ng-controller="emailSignInController")
|
||||||
h2 Sign in with an email address here:
|
h2 Sign in with an email address here:
|
||||||
form(method='POST', action='/api/user/login')
|
form(method='POST', action='/auth/local')
|
||||||
input(type='hidden', name='_csrf', value=_csrf)
|
input(type='hidden', name='_csrf', value=_csrf)
|
||||||
.col-sm-6.col-sm-offset-3
|
.col-sm-6.col-sm-offset-3
|
||||||
.form-group
|
.form-group
|
||||||
|
Reference in New Issue
Block a user