add email for backstage profile

This commit is contained in:
Tim Urista
2020-07-06 09:47:19 -07:00
parent e8a924a923
commit fe8aa15473
2 changed files with 12 additions and 1 deletions
@@ -32,7 +32,7 @@ const Component: ProviderComponent = ({ onResult }) => {
const profile = await gitlabAuthApi.getProfile();
onResult({
userId: identity?.id || profile.email,
userId: identity!.id,
profile: profile!,
getIdToken: () =>
gitlabAuthApi.getBackstageIdentity().then(i => i!.idToken),
@@ -78,6 +78,14 @@ export class GitlabAuthProvider implements OAuthProviderHandlers {
idToken: params.id_token,
};
// gitlab provides an id numeric value (123)
// as a fallback
let id = passportProfile!.id;
if (profile.email) {
id = profile.email.split('@')[0];
}
if (params.expires_in) {
providerInfo.expiresInSeconds = params.expires_in;
}
@@ -87,6 +95,9 @@ export class GitlabAuthProvider implements OAuthProviderHandlers {
return {
providerInfo,
profile,
backstageIdentity: {
id,
},
};
}