mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-10-24 23:49:06 +08:00
fix override user identity login to reformat provider
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { observeMethod, observeQuery } from '../utils/rx';
|
||||
import { getSocialProvider } from '../utils/auth';
|
||||
|
||||
export default function({ models }) {
|
||||
const { User, UserIdentity, UserCredential } = models;
|
||||
@@ -22,14 +23,14 @@ export default function({ models }) {
|
||||
console.log('provider', provider);
|
||||
console.log('id', profile.id);
|
||||
findIdent({
|
||||
provider: provider,
|
||||
provider: getSocialProvider(provider),
|
||||
externalId: profile.id
|
||||
})
|
||||
.flatMap(identity => {
|
||||
const modified = new Date();
|
||||
if (!identity || identity.externalId !== profile.id) {
|
||||
return observeQuery(UserIdentity, 'create', {
|
||||
provider,
|
||||
provider: getSocialProvider(provider),
|
||||
externalId: profile.id,
|
||||
authScheme,
|
||||
profile,
|
||||
@@ -41,7 +42,7 @@ export default function({ models }) {
|
||||
}
|
||||
identity.credentials = credentials;
|
||||
return observeQuery(identity, 'updateAttributes', {
|
||||
profile,
|
||||
profile: getSocialProvider(provider),
|
||||
credentials,
|
||||
modified
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user