fix: add missing corporateEmails enforcement to all email update paths in account.php

This commit is contained in:
harsh mahajan committed 2026-06-08 17:06:52 +05:30
1 parent 60d434f53c
commit ddf5d17f41
1 file changed
+16
+16
View File
@@ -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' => [