Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
byn9826 committed Nov 14, 2024
1 parent 2cffc89 commit b77f4b6
Show file tree
Hide file tree
Showing 27 changed files with 769 additions and 12 deletions.
11 changes: 10 additions & 1 deletion admin-panel/app/[lang]/account/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,20 @@ const Page = () => {
})
}

const handleChangeEmail = () => {
loginRedirect({
locale: locale || undefined, policy: 'change_email',
})
}

return (
<section>
<section className='flex flex-col gap-4 w-32'>
<Button onClick={handleChangePassword}>
{t('account.changePassword')}
</Button>
<Button onClick={handleChangeEmail}>
{t('account.changeEmail')}
</Button>
</section>
)
}
Expand Down
3 changes: 2 additions & 1 deletion admin-panel/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"account": "Account"
},
"account": {
"changePassword": "Change Password"
"changePassword": "Change Password",
"changeEmail": "Change Email"
},
"common": {
"enable": "Enable",
Expand Down
3 changes: 2 additions & 1 deletion admin-panel/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"account": "Compte"
},
"account": {
"changePassword": "Changer le mot de passe"
"changePassword": "Changer le mot de passe",
"changeEmail": "Changer l'email"
},
"common": {
"enable": "Activer",
Expand Down
8 changes: 8 additions & 0 deletions server/src/__tests__/normal/identity-main.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
const { code } = json as { code: string }
const codeStore = JSON.parse(await mockedKV.get(`AC-${code}`) ?? '')
Expand Down Expand Up @@ -692,6 +693,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
const appRecord = await getApp(db)
const { code } = json as { code: string }
Expand Down Expand Up @@ -755,6 +757,7 @@ describe(
requireOtpMfa: true,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
global.process.env.OTP_MFA_IS_REQUIRED = false as unknown as string
},
Expand All @@ -778,6 +781,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
global.process.env.EMAIL_MFA_IS_REQUIRED = false as unknown as string
},
Expand All @@ -801,6 +805,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: true,
requireChangePassword: false,
requireChangeEmail: false,
})
global.process.env.SMS_MFA_IS_REQUIRED = false as unknown as string
},
Expand All @@ -824,6 +829,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
global.process.env.ENFORCE_ONE_MFA_ENROLLMENT = ['email', 'otp'] as unknown as string
},
Expand All @@ -847,6 +853,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
global.process.env.ENABLE_USER_APP_CONSENT = true as unknown as string
},
Expand Down Expand Up @@ -1014,6 +1021,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
const consent = db.prepare('SELECT * from user_app_consent WHERE "userId" = 1 AND "appId" = 1').get()
expect(consent).toBeTruthy()
Expand Down
8 changes: 8 additions & 0 deletions server/src/__tests__/normal/identity-mfa.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})

const user = await db.prepare('SELECT * from "user" WHERE id = 1').get() as userModel.Raw
Expand Down Expand Up @@ -324,6 +325,7 @@ describe(
requireOtpMfa: true,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})

const user = await db.prepare('SELECT * from "user" WHERE id = 1').get() as userModel.Raw
Expand Down Expand Up @@ -547,6 +549,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
expect(await mockedKV.get(`${adapterConfig.BaseKVKey.OtpMfaCode}-${json.code}`)).toBe('1')
},
Expand Down Expand Up @@ -1520,6 +1523,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
expect(await mockedKV.get(`${adapterConfig.BaseKVKey.SmsMfaCode}-${json.code}`)).toBe('1')

Expand Down Expand Up @@ -1943,6 +1947,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
expect(await mockedKV.get(`${adapterConfig.BaseKVKey.EmailMfaCode}-${json.code}`)).toBe('1')
},
Expand Down Expand Up @@ -2042,6 +2047,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
expect(await mockedKV.get(`${adapterConfig.BaseKVKey.OtpMfaCode}-${json.code}`)).toBe('1')
},
Expand Down Expand Up @@ -2104,6 +2110,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
expect(await mockedKV.get(`${adapterConfig.BaseKVKey.SmsMfaCode}-${json.code}`)).toBe('1')
},
Expand Down Expand Up @@ -2285,6 +2292,7 @@ describe(
requireOtpMfa: false,
requireSmsMfa: false,
requireChangePassword: false,
requireChangeEmail: false,
})
expect(await mockedKV.get(`${adapterConfig.BaseKVKey.EmailMfaCode}-${json.code}`)).toBe('1')
},
Expand Down
Loading

0 comments on commit b77f4b6

Please sign in to comment.