diff --git a/src/auth/AuthGuard.ts b/src/auth/AuthGuard.ts index 4d645a3..9db2ddc 100644 --- a/src/auth/AuthGuard.ts +++ b/src/auth/AuthGuard.ts @@ -59,7 +59,8 @@ export default abstract class AuthGuard
> {
session: Express.Session,
proof: P,
onLogin?: (user: User) => Promise > {
user = await MysqlConnectionManager.wrapTransaction(async connection => {
const user = User.create({});
+ if (beforeRegister) {
+ (await beforeRegister(connection, user)).forEach(c => callbacks.push(c));
+ }
await user.save(connection, c => callbacks.push(c));
- if (onRegister) {
- (await onRegister(connection, user)).forEach(c => callbacks.push(c));
+ if (afterRegister) {
+ (await afterRegister(connection, user)).forEach(c => callbacks.push(c));
}
return user;
});
diff --git a/src/auth/magic_link/MagicLinkAuthController.ts b/src/auth/magic_link/MagicLinkAuthController.ts
index 7d44f4f..ea988d9 100644
--- a/src/auth/magic_link/MagicLinkAuthController.ts
+++ b/src/auth/magic_link/MagicLinkAuthController.ts
@@ -23,7 +23,7 @@ export default abstract class MagicLinkAuthController extends AuthController {
// Auth
try {
return await req.as(AuthMiddleware).getAuthGuard().authenticateOrRegister(
- session, magicLink, undefined, async (connection, user) => {
+ session, magicLink, undefined, undefined, async (connection, user) => {
const callbacks: RegisterCallback[] = [];
const userEmail = UserEmail.create({