diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 4a984af8f1..f944474a22 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1702,6 +1702,10 @@ Http::get('/v1/account/sessions/oauth2/:provider/redirect') $failureRedirect(Exception::USER_EMAIL_FREE); } + if ((($project->getId() === 'console') || ($plan['supportsCorporateEmailValidation'] ?? false)) && ($project->getAttribute('auths', [])['corporateEmails'] ?? false) && !($emailMetadata['emailIsCorporate'] ?? true)) { + $failureRedirect(Exception::USER_EMAIL_NOT_CORPORATE); + } + try { $userId = ID::unique(); $user->setAttributes([ @@ -1843,6 +1847,10 @@ Http::get('/v1/account/sessions/oauth2/:provider/redirect') $failureRedirect(Exception::USER_EMAIL_FREE); } + if ((($project->getId() === 'console') || ($plan['supportsCorporateEmailValidation'] ?? false)) && ($project->getAttribute('auths', [])['corporateEmails'] ?? false) && !($emailMetadata['emailIsCorporate'] ?? true)) { + $failureRedirect(Exception::USER_EMAIL_NOT_CORPORATE); + } + $user->setAttribute('email', $email); $user->setAttribute('emailCanonical', $emailMetadata['emailCanonical']); $user->setAttribute('emailIsCanonical', $emailMetadata['emailIsCanonical']); @@ -2201,6 +2209,10 @@ Http::post('/v1/account/tokens/magic-url') throw new Exception(Exception::USER_EMAIL_FREE); } + if ((($project->getId() === 'console') || ($plan['supportsCorporateEmailValidation'] ?? false)) && ($project->getAttribute('auths', [])['corporateEmails'] ?? false) && !($emailMetadata['emailIsCorporate'] ?? true)) { + throw new Exception(Exception::USER_EMAIL_NOT_CORPORATE); + } + $user->setAttributes([ '$id' => $userId, '$permissions' => [ @@ -2521,6 +2533,10 @@ Http::post('/v1/account/tokens/email') throw new Exception(Exception::USER_EMAIL_FREE); } + if ((($project->getId() === 'console') || ($plan['supportsCorporateEmailValidation'] ?? false)) && ($project->getAttribute('auths', [])['corporateEmails'] ?? false) && !($emailMetadata['emailIsCorporate'] ?? true)) { + throw new Exception(Exception::USER_EMAIL_NOT_CORPORATE); + } + $user->setAttributes([ '$id' => $userId, '$permissions' => [