feat(server): introduce user friendly server errors (#7111)

This commit is contained in:
liuyi
2024-06-17 11:30:58 +08:00
committed by GitHub
parent 5307a55f8a
commit 54fc1197ad
65 changed files with 3170 additions and 924 deletions
@@ -66,7 +66,7 @@ test('should throw if email duplicated', async t => {
const { auth } = t.context;
await t.throwsAsync(() => auth.signUp('u1', 'u1@affine.pro', '1'), {
message: 'Email was taken',
message: 'This email has already been registered.',
});
});
@@ -82,7 +82,7 @@ test('should throw if user not found', async t => {
const { auth } = t.context;
await t.throwsAsync(() => auth.signIn('u2@affine.pro', '1'), {
message: 'Invalid sign in credentials',
message: 'Wrong user email or password.',
});
});
@@ -95,7 +95,8 @@ test('should throw if password not set', async t => {
});
await t.throwsAsync(() => auth.signIn('u2@affine.pro', '1'), {
message: 'User Password is not set. Should login through email link.',
message:
'You are trying to sign in by a different method than you signed up with.',
});
});
@@ -103,7 +104,7 @@ test('should throw if password not match', async t => {
const { auth } = t.context;
await t.throwsAsync(() => auth.signIn('u1@affine.pro', '2'), {
message: 'Invalid sign in credentials',
message: 'Wrong user email or password.',
});
});
@@ -118,7 +119,7 @@ test('should be able to change password', async t => {
await t.throwsAsync(
() => auth.signIn('u1@affine.pro', '1' /* old password */),
{
message: 'Invalid sign in credentials',
message: 'Wrong user email or password.',
}
);
@@ -135,7 +136,7 @@ test('should be able to change email', async t => {
await auth.changeEmail(u1.id, 'u2@affine.pro');
await t.throwsAsync(() => auth.signIn('u1@affine.pro' /* old email */, '1'), {
message: 'Invalid sign in credentials',
message: 'Wrong user email or password.',
});
signedInU1 = await auth.signIn('u2@affine.pro', '1');