@@ -10,6 +10,7 @@ import {
1010 updatePrimaryEmail ,
1111 updatePrimaryPhone ,
1212} from '#src/api/my-account.js' ;
13+ import { updateSignInExperience } from '#src/api/sign-in-experience.js' ;
1314import {
1415 createAndVerifyVerificationCode ,
1516 createVerificationRecordByPassword ,
@@ -22,7 +23,7 @@ import {
2223 signInAndGetUserApi ,
2324} from '#src/helpers/profile.js' ;
2425import { enableAllPasswordSignInMethods } from '#src/helpers/sign-in-experience.js' ;
25- import { generateEmail , generatePhone } from '#src/utils.js' ;
26+ import { devFeatureTest , generateEmail , generatePhone } from '#src/utils.js' ;
2627
2728describe ( 'account (email and phone)' , ( ) => {
2829 beforeAll ( async ( ) => {
@@ -137,6 +138,36 @@ describe('account (email and phone)', () => {
137138
138139 await deleteDefaultTenantUser ( user . id ) ;
139140 } ) ;
141+
142+ devFeatureTest . it ( 'should reject the email if the email is in the blocklist' , async ( ) => {
143+ const email = generateEmail ( ) ;
144+ await updateSignInExperience ( {
145+ emailBlocklistPolicy : {
146+ customBlocklist : [ email ] ,
147+ } ,
148+ } ) ;
149+
150+ const { user, username, password } = await createDefaultTenantUserWithPassword ( ) ;
151+ const api = await signInAndGetUserApi ( username , password , {
152+ scopes : [ UserScope . Profile , UserScope . Email ] ,
153+ } ) ;
154+
155+ const verificationRecordId = await createVerificationRecordByPassword ( api , password ) ;
156+ const newVerificationRecordId = await createAndVerifyVerificationCode ( api , {
157+ type : SignInIdentifier . Email ,
158+ value : email ,
159+ } ) ;
160+
161+ await expectRejects (
162+ updatePrimaryEmail ( api , email , verificationRecordId , newVerificationRecordId ) ,
163+ {
164+ code : 'session.email_blocklist.email_not_allowed' ,
165+ status : 422 ,
166+ }
167+ ) ;
168+
169+ await deleteDefaultTenantUser ( user . id ) ;
170+ } ) ;
140171 } ) ;
141172
142173 describe ( 'DELETE /my-account/primary-email' , ( ) => {
0 commit comments