Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
window['FB'].api('/me', { fields }, async response => {
const user = {
name: response.name,
email: response.email,
};
await Auth.federatedSignIn('facebook', { token: accessToken, expires_at }, user);
const authenticatedUser = await Auth.currentAuthenticatedUser();
this.handleAuthStateChange(AuthState.SignedIn, authenticatedUser);
});
};const user = {
name: userInfo.profile.Name,
email: userInfo.profile.PrimaryEmail,
};
if (
!Auth ||
typeof Auth.federatedSignIn !== 'function' ||
typeof Auth.currentAuthenticatedUser !== 'function'
) {
throw new Error(
'No Auth module found, please ensure @aws-amplify/auth is imported'
);
}
Auth.federatedSignIn(
'amazon',
{ token: access_token, expires_at },
user
)
.then(credentials => {
return Auth.currentAuthenticatedUser();
})
.then(authUser => {
if (onStateChange) {
onStateChange('signedIn', authUser);
}
});
});
}signInWithOAuth(event) {
event.preventDefault();
Auth.federatedSignIn();
}window['amazon'].Login.retrieveProfile(async userInfo => {
if (!userInfo.success) {
return logger.debug('Get user Info failed');
}
const user = {
name: userInfo.profile.Name,
email: userInfo.profile.PrimaryEmail,
};
await Auth.federatedSignIn('amazon', { token: access_token, expires_at }, user);
const authenticatedUser = await Auth.currentAuthenticatedUser();
this.handleAuthStateChange(AuthState.SignedIn, authenticatedUser);
});
};handleUser = async user => {
if (!Auth || typeof Auth.federatedSignIn !== 'function' || typeof Auth.currentAuthenticatedUser !== 'function') {
throw new Error(NO_AUTH_MODULE_FOUND);
}
try {
window.localStorage.setItem(AUTH_SOURCE_KEY, JSON.stringify({ provider: 'google' }));
} catch (e) {
logger.debug('Failed to cache auth source into localStorage', e);
}
const { id_token, expires_at } = user.getAuthResponse();
const profile = user.getBasicProfile();
await Auth.federatedSignIn(
'google',
{ token: id_token, expires_at },
{
email: profile.getEmail(),
name: profile.getName(),
picture: profile.getImageUrl(),
},
);
const authenticatedUser = await Auth.currentAuthenticatedUser();
try {
this.handleAuthStateChange(AuthState.SignedIn, authenticatedUser);
} catch (error) {
this.handleError(error);
}signIn(_e, provider) {
Auth.federatedSignIn({ provider });
}fb.api('/me', { fields: 'name,email' }, response => {
const user = {
name: response.name,
email: response.email,
};
if (
!Auth ||
typeof Auth.federatedSignIn !== 'function' ||
typeof Auth.currentAuthenticatedUser !== 'function'
) {
throw new Error(
'No Auth module found, please ensure @aws-amplify/auth is imported'
);
}
Auth.federatedSignIn(
'facebook',
{ token: accessToken, expires_at },
user
)
.then(credentials => {
return Auth.currentAuthenticatedUser();
})
.then(authUser => {
if (onStateChange) {
onStateChange('signedIn', authUser);
}
});
});
}this._auth0.client.userInfo(authResult.accessToken, async (err, user) => {
let username = undefined;
let email = undefined;
if (err) {
logger.debug('Failed to get the user info', err);
} else {
username = user.name;
email = user.email;
}
await Auth.federatedSignIn(
config.domain,
{
token: authResult.idToken,
expires_at: authResult.expiresIn * 1000 + new Date().getTime(),
},
{ name: username, email },
);
const authenticatedUser = await Auth.currentAuthenticatedUser();
this.handleAuthStateChange(AuthState.SignedIn, authenticatedUser);
});
});