Improve verbosity of auth error
This commit is contained in:
parent
5731409c51
commit
8882df4c0d
@ -47,7 +47,7 @@ export default abstract class AuthGuard<P extends AuthProof> {
|
|||||||
throw new Error('Unable to register user.');
|
throw new Error('Unable to register user.');
|
||||||
}
|
}
|
||||||
} else if (registerCallback) {
|
} else if (registerCallback) {
|
||||||
throw new AuthError('User already exists.');
|
throw new UserAlreadyExistsAuthError(await proof.getEmail());
|
||||||
}
|
}
|
||||||
|
|
||||||
session.auth_id = user.id;
|
session.auth_id = user.id;
|
||||||
@ -84,3 +84,12 @@ export class AuthError extends Error {
|
|||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class UserAlreadyExistsAuthError extends AuthError {
|
||||||
|
public readonly email: string;
|
||||||
|
|
||||||
|
constructor(userEmail: string) {
|
||||||
|
super(`User with email ${userEmail} already exists.`);
|
||||||
|
this.email = userEmail;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user