fix: add user object to Observables

This commit is contained in:
Mrugesh Mohapatra
2018-05-20 13:40:15 +05:30
parent 4d48175e64
commit c6b62fc7ab
3 changed files with 6 additions and 5 deletions

View File

@ -14,7 +14,6 @@ import { wrapHandledError } from '../../server/utils/create-handled-error.js';
export default function(UserIdent) {
UserIdent.on('dataSourceAttached', () => {
UserIdent.findOne$ = observeMethod(UserIdent, 'findOne');
UserIdent.create$ = observeMethod(UserIdent, 'create');
});
// original source
// github.com/strongloop/loopback-component-passport
@ -65,6 +64,7 @@ export default function(UserIdent) {
);
} else {
return UserIdent.findOne$(query)
.flatMap(identity => {
if (!identity) {
@ -76,7 +76,7 @@ export default function(UserIdent) {
Please create an account below
`,
type: 'info',
redirectTo: '/deprecated-signup'
redirectTo: '/signup'
}
);
}
@ -96,7 +96,7 @@ export default function(UserIdent) {
new Error('user identity is not associated with a user'),
{
type: 'info',
redirectTo: '/deprecated-signup',
redirectTo: '/signup',
message: dedent`
The user account associated with the ${provider} user ${username || 'Anon'}
no longer exists.
@ -131,6 +131,7 @@ export default function(UserIdent) {
}
);
return Observable.combineLatest(
Observable.of(user),
updateIdentity,
createToken,
(user, identity, token) => ({ user, identity, token })

View File

@ -104,7 +104,7 @@ export default function setupPassport(app) {
return config.successRedirect || '';
};
config.customCallback = !config.redirectWithToken
config.customCallback = !config.useCustomCallback
? null
: (req, res, next) => {

View File

@ -176,7 +176,7 @@ export default {
callbackURL: '/auth/auth0/callback',
authPath: '/auth/auth0',
callbackPath: '/auth/auth0/callback',
redirectWithToken: true,
useCustomCallback: true,
successRedirect: successRedirect,
failureRedirect: failureRedirect,
scope: ['openid email'],