1- import 'reflect-metadata' ;
21import { env } from 'process' ;
2+ import 'reflect-metadata' ;
33
44import { logger } from '@user-office-software/duo-logger' ;
55import { OpenIdClient } from '@user-office-software/openid' ;
@@ -128,9 +128,9 @@ export class OAuthAuthorization extends UserAuthorization {
128128 ) : Promise < User > {
129129 const client = await OpenIdClient . getInstance ( ) ;
130130 const institution = await this . getOrCreateUserInstitution ( userInfo ) ;
131- const userWithOAuthSubMatch = await this . userDataSource . getByOIDCSub (
132- userInfo . sub
133- ) ;
131+ const userId = this . getUniqueId ( userInfo ) ;
132+ const userWithOAuthSubMatch =
133+ await this . userDataSource . getByOIDCSub ( userId ) ;
134134
135135 const userWithEmailMatch = await this . userDataSource . getByEmail (
136136 userInfo . email
@@ -146,7 +146,7 @@ export class OAuthAuthorization extends UserAuthorization {
146146 lastname : userInfo . family_name ,
147147 oauthIssuer : client . issuer . metadata . issuer ,
148148 oauthRefreshToken : tokenSet . refresh_token ?? '' ,
149- oidcSub : userInfo . sub ,
149+ oidcSub : userId ,
150150 institutionId : institution ?. id ?? user . institutionId ,
151151 preferredname : userInfo . preferred_username ,
152152 user_title : userInfo . title as string ,
@@ -159,7 +159,7 @@ export class OAuthAuthorization extends UserAuthorization {
159159 userInfo . given_name ,
160160 userInfo . family_name ,
161161 userInfo . preferred_username ?? '' ,
162- userInfo . sub ,
162+ userId ,
163163 tokenSet . refresh_token ?? '' ,
164164 client . issuer . metadata . issuer ,
165165 institution ?. id ?? 1 ,
0 commit comments