1313 * via an SSO strategy, we link this passport to your exsiting account. There is just one exception, 
1414 * which are SSO strategies which "exclusively" manage a domain. 
1515 * 2. If you're not signed in and try to sign in, this checks if there is already an account – and creates it if not. 
16-  * 3. If you sign in and the SSO strategy is set to "update_on_login", it will reset the name of the user to the 
17-  * data from the SSO provider. However, the user can still modify the name. 
16+  * 3. If you sign in and the SSO strategy is set to "update_on_login", 
17+  * it will reset the name of the user to the data from the SSO provider. 
18+  * Users can only modify their first and last name, if that SSO mechanism isn't exclusive! 
1819 * 4. If you already have an email address belonging to a newly introduced exclusive domain, it will start to be controlled by it. 
1920 */ 
2021
@@ -45,8 +46,9 @@ import { sanitizeProfile } from "@cocalc/server/auth/sso/sanitize-profile";
4546import  {  callback2  as  cb2  }  from  "@cocalc/util/async-utils" ; 
4647import  {  is_valid_email_address  }  from  "@cocalc/util/misc" ; 
4748import  {  HELP_EMAIL  }  from  "@cocalc/util/theme" ; 
48- import  {  emailBelongsToDomain ,   getEmailDomain   }  from  "./ check-required-sso" ; 
49+ import  {  emailBelongsToDomain   }  from  "@cocalc/util/auth- check-required-sso" ; 
4950import  {  SSO_API_KEY_COOKIE_NAME  }  from  "./consts" ; 
51+ import  {  getEmailDomain  }  from  "@cocalc/util/auth-check-required-sso" ; 
5052
5153const  logger  =  getLogger ( "server:auth:sso:passport-login" ) ; 
5254
@@ -240,7 +242,7 @@ export class PassportLogin {
240242    const  exclusiveDomains  =  strategy . info ?. exclusive_domains  ??  [ ] ; 
241243    if  ( ! isEmpty ( exclusiveDomains ) )  { 
242244      for  ( const  email  of  opts . emails  ??  [ ] )  { 
243-         const  emailDomain  =  getEmailDomain ( email . toLocaleLowerCase ( ) ) ; 
245+         const  emailDomain  =  getEmailDomain ( email . toLowerCase ( ) ) ; 
244246        for  ( const  ssoDomain  of  exclusiveDomains )  { 
245247          if  ( emailBelongsToDomain ( emailDomain ,  ssoDomain ) )  { 
246248            return  true ; 
@@ -253,7 +255,7 @@ export class PassportLogin {
253255
254256  // similar to the above, for a specific email address 
255257  private  checkEmailExclusiveSSO ( email_address : string ) : boolean  { 
256-     const  emailDomain  =  getEmailDomain ( email_address . toLocaleLowerCase ( ) ) ; 
258+     const  emailDomain  =  getEmailDomain ( email_address . toLowerCase ( ) ) ; 
257259    for  ( const  strategyName  in  this . opts . passports )  { 
258260      const  strategy  =  this . opts . passports [ strategyName ] ; 
259261      for  ( const  ssoDomain  of  strategy . info ?. exclusive_domains  ??  [ ] )  { 
@@ -510,7 +512,7 @@ export class PassportLogin {
510512    } 
511513
512514    // We update the email address, if it does not belong to another account. 
513-    
515+ 
514516    if  ( is_valid_email_address ( locals . email_address ) )  { 
515517      upd . email_address  =  locals . email_address ; 
516518    } 
0 commit comments