mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
fix(core): fix empty error message (#3202)
This commit is contained in:
parent
0e9d851f68
commit
af66760a42
1 changed files with 15 additions and 14 deletions
|
@ -4,9 +4,10 @@ import { SignInMode, SignInIdentifier, InteractionEvent } from '@logto/schemas';
|
|||
import RequestError from '#src/errors/RequestError/index.js';
|
||||
import assertThat from '#src/utils/assert-that.js';
|
||||
|
||||
const forbiddenEventError = new RequestError({ code: 'auth.forbidden', status: 403 });
|
||||
const forbiddenEventError = () => new RequestError({ code: 'auth.forbidden', status: 403 });
|
||||
|
||||
const forbiddenIdentifierError = new RequestError({
|
||||
const forbiddenIdentifierError = () =>
|
||||
new RequestError({
|
||||
code: 'user.sign_in_method_not_enabled',
|
||||
status: 422,
|
||||
});
|
||||
|
@ -16,11 +17,11 @@ export const verifySignInModeSettings = (
|
|||
{ signInMode }: SignInExperience
|
||||
) => {
|
||||
if (event === InteractionEvent.SignIn) {
|
||||
assertThat(signInMode !== SignInMode.Register, forbiddenEventError);
|
||||
assertThat(signInMode !== SignInMode.Register, forbiddenEventError());
|
||||
}
|
||||
|
||||
if (event === InteractionEvent.Register) {
|
||||
assertThat(signInMode !== SignInMode.SignIn, forbiddenEventError);
|
||||
assertThat(signInMode !== SignInMode.SignIn, forbiddenEventError());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,7 +37,7 @@ export const verifyIdentifierSettings = (
|
|||
signIn.methods.some(
|
||||
({ identifier: method, password }) => method === SignInIdentifier.Username && password
|
||||
),
|
||||
forbiddenIdentifierError
|
||||
forbiddenIdentifierError()
|
||||
);
|
||||
|
||||
return;
|
||||
|
@ -67,7 +68,7 @@ export const verifyIdentifierSettings = (
|
|||
|
||||
return true;
|
||||
}),
|
||||
forbiddenIdentifierError
|
||||
forbiddenIdentifierError()
|
||||
);
|
||||
|
||||
return;
|
||||
|
@ -98,7 +99,7 @@ export const verifyIdentifierSettings = (
|
|||
|
||||
return true;
|
||||
}),
|
||||
forbiddenIdentifierError
|
||||
forbiddenIdentifierError()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -107,18 +108,18 @@ export const verifyIdentifierSettings = (
|
|||
|
||||
export const verifyProfileSettings = (profile: Profile, { signUp }: SignInExperience) => {
|
||||
if (profile.phone) {
|
||||
assertThat(signUp.identifiers.includes(SignInIdentifier.Phone), forbiddenIdentifierError);
|
||||
assertThat(signUp.identifiers.includes(SignInIdentifier.Phone), forbiddenIdentifierError());
|
||||
}
|
||||
|
||||
if (profile.email) {
|
||||
assertThat(signUp.identifiers.includes(SignInIdentifier.Email), forbiddenIdentifierError);
|
||||
assertThat(signUp.identifiers.includes(SignInIdentifier.Email), forbiddenIdentifierError());
|
||||
}
|
||||
|
||||
if (profile.username) {
|
||||
assertThat(signUp.identifiers.includes(SignInIdentifier.Username), forbiddenIdentifierError);
|
||||
assertThat(signUp.identifiers.includes(SignInIdentifier.Username), forbiddenIdentifierError());
|
||||
}
|
||||
|
||||
if (profile.password) {
|
||||
assertThat(signUp.password, forbiddenIdentifierError);
|
||||
assertThat(signUp.password, forbiddenIdentifierError());
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue