mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
fix(core): sign in method requires at least one factor (#2384)
This commit is contained in:
parent
81aa4cd8ed
commit
697b84f3eb
9 changed files with 49 additions and 0 deletions
|
@ -218,6 +218,7 @@ describe('validate sign-in', () => {
|
|||
...mockSignInMethod,
|
||||
identifier: SignInIdentifier.Email,
|
||||
password: false,
|
||||
verificationCode: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -261,4 +262,38 @@ describe('validate sign-in', () => {
|
|||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('throws when verification code and password are both disabled', () => {
|
||||
expect(() => {
|
||||
validateSignIn(
|
||||
{
|
||||
methods: [
|
||||
{
|
||||
...mockSignInMethod,
|
||||
identifier: SignInIdentifier.Email,
|
||||
verificationCode: false,
|
||||
password: false,
|
||||
},
|
||||
{
|
||||
...mockSignInMethod,
|
||||
identifier: SignInIdentifier.Sms,
|
||||
verificationCode: true,
|
||||
password: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
...mockSignUp,
|
||||
identifier: SignUpIdentifier.Sms,
|
||||
password: false,
|
||||
verify: true,
|
||||
},
|
||||
enabledConnectors
|
||||
);
|
||||
}).toMatchError(
|
||||
new RequestError({
|
||||
code: 'sign_in_experiences.at_least_one_authentication_factor',
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,6 +31,13 @@ export const validateSignIn = (
|
|||
);
|
||||
}
|
||||
|
||||
assertThat(
|
||||
signIn.methods.every(({ password, verificationCode }) => password || verificationCode),
|
||||
new RequestError({
|
||||
code: 'sign_in_experiences.at_least_one_authentication_factor',
|
||||
})
|
||||
);
|
||||
|
||||
switch (signUp.identifier) {
|
||||
case SignUpIdentifier.Username: {
|
||||
assertThat(
|
||||
|
|
|
@ -128,6 +128,7 @@ const errors = {
|
|||
code_sign_in_must_be_enabled:
|
||||
'Verification code sign in must be enabled when set a password is not required in sign up.', // UNTRANSLATED
|
||||
unsupported_default_language: 'Die Sprache - {{language}} wird momentan nicht unterstützt.',
|
||||
at_least_one_authentication_factor: 'You have to select at least one authentication factor.', // UNTRANSLATED
|
||||
},
|
||||
localization: {
|
||||
cannot_delete_default_language:
|
||||
|
|
|
@ -126,6 +126,7 @@ const errors = {
|
|||
code_sign_in_must_be_enabled:
|
||||
'Verification code sign in must be enabled when set a password is not required in sign up.',
|
||||
unsupported_default_language: 'This language - {{language}} is not supported at the moment.',
|
||||
at_least_one_authentication_factor: 'You have to select at least one authentication factor.',
|
||||
},
|
||||
localization: {
|
||||
cannot_delete_default_language:
|
||||
|
|
|
@ -134,6 +134,7 @@ const errors = {
|
|||
code_sign_in_must_be_enabled:
|
||||
'Verification code sign in must be enabled when set a password is not required in sign up.', // UNTRANSLATED
|
||||
unsupported_default_language: 'This language - {{language}} is not supported at the moment.', // UNTRANSLATED
|
||||
at_least_one_authentication_factor: 'You have to select at least one authentication factor.', // UNTRANSLATED
|
||||
},
|
||||
localization: {
|
||||
cannot_delete_default_language:
|
||||
|
|
|
@ -123,6 +123,7 @@ const errors = {
|
|||
code_sign_in_must_be_enabled:
|
||||
'Verification code sign in must be enabled when set a password is not required in sign up.', // UNTRANSLATED
|
||||
unsupported_default_language: 'This language - {{language}} is not supported at the moment.', // UNTRANSLATED
|
||||
at_least_one_authentication_factor: 'You have to select at least one authentication factor.', // UNTRANSLATED
|
||||
},
|
||||
localization: {
|
||||
cannot_delete_default_language:
|
||||
|
|
|
@ -129,6 +129,7 @@ const errors = {
|
|||
code_sign_in_must_be_enabled:
|
||||
'Verification code sign in must be enabled when set a password is not required in sign up.', // UNTRANSLATED
|
||||
unsupported_default_language: 'This language - {{language}} is not supported at the moment.', // UNTRANSLATED
|
||||
at_least_one_authentication_factor: 'You have to select at least one authentication factor.', // UNTRANSLATED
|
||||
},
|
||||
localization: {
|
||||
cannot_delete_default_language:
|
||||
|
|
|
@ -127,6 +127,7 @@ const errors = {
|
|||
code_sign_in_must_be_enabled:
|
||||
'Verification code sign in must be enabled when set a password is not required in sign up.', // UNTRANSLATED
|
||||
unsupported_default_language: 'This language - {{language}} is not supported at the moment.', // UNTRANSLATED
|
||||
at_least_one_authentication_factor: 'You have to select at least one authentication factor.', // UNTRANSLATED
|
||||
},
|
||||
localization: {
|
||||
cannot_delete_default_language:
|
||||
|
|
|
@ -119,6 +119,7 @@ const errors = {
|
|||
code_sign_in_must_be_enabled:
|
||||
'Verification code sign in must be enabled when set a password is not required in sign up.', // UNTRANSLATED
|
||||
unsupported_default_language: '{{language}}无法选择为默认语言。',
|
||||
at_least_one_authentication_factor: '至少要选择一个登录要素',
|
||||
},
|
||||
localization: {
|
||||
cannot_delete_default_language: '你已设置{{languageTag}}为你的默认语言,你无法删除默认语言。',
|
||||
|
|
Loading…
Add table
Reference in a new issue