Merge pull request #656 from coralproject/service-fix

Resolve facebook login issue
This commit is contained in:
Kiwi
2017-06-07 16:57:19 +07:00
committed by GitHub
2 changed files with 14 additions and 8 deletions
+1
View File
@@ -40,6 +40,7 @@ const SetTokenForSafari = (req, res, token) => {
if (browser.ios || browser.safari) {
res.cookie('authorization', token, {
httpOnly: true,
secure: process.env.NODE_ENV === 'production',
expires: new Date(Date.now() + ms(JWT_EXPIRY))
});
}
+13 -8
View File
@@ -930,16 +930,21 @@ module.exports = class UsersService {
// Extract all the tokenUserNotFound plugins so we can integrate with other
// providers.
const tokenUserNotFoundHooks = require('./plugins')
.get('server', 'tokenUserNotFound')
.map(({plugin, tokenUserNotFound}) => {
debug(`added plugin '${plugin.name}' to tokenUserNotFound hooks`);
let tokenUserNotFoundHooks = null;
return tokenUserNotFound;
});
// Provide a function that
// Provide a function that can loop over the hooks and search for a provider
// can crack the token to a user.
const lookupUserNotFound = async (token) => {
if (!Array.isArray(tokenUserNotFoundHooks)) {
tokenUserNotFoundHooks = require('./plugins')
.get('server', 'tokenUserNotFound')
.map(({plugin, tokenUserNotFound}) => {
debug(`added plugin '${plugin.name}' to tokenUserNotFound hooks`);
return tokenUserNotFound;
});
}
for (let hook of tokenUserNotFoundHooks) {
let user = await hook(token);
if (user !== null && typeof user !== 'undefined') {