Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging
This commit is contained in:
@ -49,6 +49,7 @@ module.exports = function(User) {
|
|||||||
|
|
||||||
// username should be unique
|
// username should be unique
|
||||||
User.validatesUniquenessOf('username');
|
User.validatesUniquenessOf('username');
|
||||||
|
User.settings.emailVerificationRequired = false;
|
||||||
|
|
||||||
User.observe('before save', function({ instance: user }, next) {
|
User.observe('before save', function({ instance: user }, next) {
|
||||||
if (user) {
|
if (user) {
|
||||||
@ -84,10 +85,16 @@ module.exports = function(User) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
User.on('resetPasswordRequest', function(info) {
|
User.on('resetPasswordRequest', function(info) {
|
||||||
|
let url;
|
||||||
const host = User.app.get('host');
|
const host = User.app.get('host');
|
||||||
// TODO(berks) get protocol as well
|
const { id: token } = info.accessToken;
|
||||||
const url = `http://${host}/reset-password?access_token=` +
|
if (process.env.NODE_ENV === 'development') {
|
||||||
info.accessToken.id;
|
const port = User.app.get('port');
|
||||||
|
url = `http://${host}:${port}/reset-password?access_token=${token}`;
|
||||||
|
} else {
|
||||||
|
url =
|
||||||
|
`http://freecodecamp.com/reset-password?access_token=${token}`;
|
||||||
|
}
|
||||||
|
|
||||||
// the email of the requested user
|
// the email of the requested user
|
||||||
debug(info.email);
|
debug(info.email);
|
||||||
@ -116,25 +123,27 @@ module.exports = function(User) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
User.afterRemote('login', function(ctx, user, next) {
|
User.afterRemote('login', function(ctx, accessToken, next) {
|
||||||
var res = ctx.res;
|
var res = ctx.res;
|
||||||
var req = ctx.req;
|
var req = ctx.req;
|
||||||
// var args = ctx.args;
|
// var args = ctx.args;
|
||||||
|
|
||||||
var accessToken = {};
|
|
||||||
var config = {
|
var config = {
|
||||||
signed: !!req.signedCookies,
|
signed: !!req.signedCookies,
|
||||||
maxAge: accessToken.ttl
|
maxAge: accessToken.ttl
|
||||||
};
|
};
|
||||||
|
|
||||||
if (accessToken && accessToken.id) {
|
if (accessToken && accessToken.id) {
|
||||||
|
debug('setting cookies');
|
||||||
res.cookie('access_token', accessToken.id, config);
|
res.cookie('access_token', accessToken.id, config);
|
||||||
res.cookie('userId', accessToken.userId, config);
|
res.cookie('userId', accessToken.userId, config);
|
||||||
}
|
}
|
||||||
debug('before pass login');
|
|
||||||
return req.logIn(user, function(err) {
|
return req.logIn({ id: accessToken.userId.toString() }, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
debug('user logged in');
|
||||||
req.flash('success', { msg: 'Success! You are logged in.' });
|
req.flash('success', { msg: 'Success! You are logged in.' });
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
});
|
});
|
||||||
@ -151,7 +160,7 @@ module.exports = function(User) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
User.afterRemote('logout', function(ctx, result, next) {
|
User.afterRemote('logout', function(ctx, result, next) {
|
||||||
var res = ctx.result;
|
var res = ctx.res;
|
||||||
res.clearCookie('access_token');
|
res.clearCookie('access_token');
|
||||||
res.clearCookie('userId');
|
res.clearCookie('userId');
|
||||||
next();
|
next();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
"name": "user",
|
"name": "user",
|
||||||
"base": "User",
|
"base": "User",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
"emailVerificationRequired": false,
|
||||||
"idInjection": true,
|
"idInjection": true,
|
||||||
"trackChanges": false,
|
"trackChanges": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
|
@ -49,10 +49,7 @@
|
|||||||
},
|
},
|
||||||
"user": {
|
"user": {
|
||||||
"dataSource": "db",
|
"dataSource": "db",
|
||||||
"public": true,
|
"public": true
|
||||||
"options": {
|
|
||||||
"emailVerificationRequired": true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"userCredential": {
|
"userCredential": {
|
||||||
"dataSource": "db",
|
"dataSource": "db",
|
||||||
|
@ -18,8 +18,7 @@ block content
|
|||||||
i.fa.fa-linkedin
|
i.fa.fa-linkedin
|
||||||
| Sign in with LinkedIn
|
| Sign in with LinkedIn
|
||||||
br
|
br
|
||||||
p Email sign in is temporarily disabled - we are working to fix this ASAP.
|
p
|
||||||
//p
|
a(href="/email-signup") Or sign up using your email address here.
|
||||||
// a(href="/email-signup") Or sign up using your email address here.
|
p
|
||||||
//p
|
a(href="/email-signin") Sign in to your existing account with your email address here.
|
||||||
// a(href="/email-signin") Sign in to your existing account with your email address here.
|
|
||||||
|
Reference in New Issue
Block a user