fix: add user object to Observables
This commit is contained in:
@ -14,7 +14,6 @@ import { wrapHandledError } from '../../server/utils/create-handled-error.js';
|
|||||||
export default function(UserIdent) {
|
export default function(UserIdent) {
|
||||||
UserIdent.on('dataSourceAttached', () => {
|
UserIdent.on('dataSourceAttached', () => {
|
||||||
UserIdent.findOne$ = observeMethod(UserIdent, 'findOne');
|
UserIdent.findOne$ = observeMethod(UserIdent, 'findOne');
|
||||||
UserIdent.create$ = observeMethod(UserIdent, 'create');
|
|
||||||
});
|
});
|
||||||
// original source
|
// original source
|
||||||
// github.com/strongloop/loopback-component-passport
|
// github.com/strongloop/loopback-component-passport
|
||||||
@ -65,6 +64,7 @@ export default function(UserIdent) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return UserIdent.findOne$(query)
|
return UserIdent.findOne$(query)
|
||||||
.flatMap(identity => {
|
.flatMap(identity => {
|
||||||
if (!identity) {
|
if (!identity) {
|
||||||
@ -76,7 +76,7 @@ export default function(UserIdent) {
|
|||||||
Please create an account below
|
Please create an account below
|
||||||
`,
|
`,
|
||||||
type: 'info',
|
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'),
|
new Error('user identity is not associated with a user'),
|
||||||
{
|
{
|
||||||
type: 'info',
|
type: 'info',
|
||||||
redirectTo: '/deprecated-signup',
|
redirectTo: '/signup',
|
||||||
message: dedent`
|
message: dedent`
|
||||||
The user account associated with the ${provider} user ${username || 'Anon'}
|
The user account associated with the ${provider} user ${username || 'Anon'}
|
||||||
no longer exists.
|
no longer exists.
|
||||||
@ -131,6 +131,7 @@ export default function(UserIdent) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
return Observable.combineLatest(
|
return Observable.combineLatest(
|
||||||
|
Observable.of(user),
|
||||||
updateIdentity,
|
updateIdentity,
|
||||||
createToken,
|
createToken,
|
||||||
(user, identity, token) => ({ user, identity, token })
|
(user, identity, token) => ({ user, identity, token })
|
||||||
|
@ -104,7 +104,7 @@ export default function setupPassport(app) {
|
|||||||
return config.successRedirect || '';
|
return config.successRedirect || '';
|
||||||
};
|
};
|
||||||
|
|
||||||
config.customCallback = !config.redirectWithToken
|
config.customCallback = !config.useCustomCallback
|
||||||
? null
|
? null
|
||||||
: (req, res, next) => {
|
: (req, res, next) => {
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ export default {
|
|||||||
callbackURL: '/auth/auth0/callback',
|
callbackURL: '/auth/auth0/callback',
|
||||||
authPath: '/auth/auth0',
|
authPath: '/auth/auth0',
|
||||||
callbackPath: '/auth/auth0/callback',
|
callbackPath: '/auth/auth0/callback',
|
||||||
redirectWithToken: true,
|
useCustomCallback: true,
|
||||||
successRedirect: successRedirect,
|
successRedirect: successRedirect,
|
||||||
failureRedirect: failureRedirect,
|
failureRedirect: failureRedirect,
|
||||||
scope: ['openid email'],
|
scope: ['openid email'],
|
||||||
|
Reference in New Issue
Block a user