diff --git a/src/auth/AuthGuard.ts b/src/auth/AuthGuard.ts index 15e5a46..a808a87 100644 --- a/src/auth/AuthGuard.ts +++ b/src/auth/AuthGuard.ts @@ -12,7 +12,7 @@ export default abstract class AuthGuard
{
return await User.getById {
main: true,
});
await userEmail.save(connection, c => callbacks.push(c));
+ if (registerCallback) {
+ (await registerCallback(connection, user.id!)).forEach(c => callbacks.push(c));
+ }
});
for (const callback of callbacks) {
@@ -43,6 +46,8 @@ export default abstract class AuthGuard {
if (!user) {
throw new Error('Unable to register user.');
}
+ } else if (registerCallback) {
+ throw new AuthError('User already exists.');
}
session.auth_id = user.id;