diff --git a/src/auth/magic_link/MagicLinkAuthMethod.ts b/src/auth/magic_link/MagicLinkAuthMethod.ts index f58156e..52eba91 100644 --- a/src/auth/magic_link/MagicLinkAuthMethod.ts +++ b/src/auth/magic_link/MagicLinkAuthMethod.ts @@ -11,6 +11,7 @@ import RedirectBackComponent from "../../components/RedirectBackComponent"; import Application from "../../Application"; import {MailTemplate} from "../../mail/Mail"; import AuthMagicLinkActionType from "./AuthMagicLinkActionType"; +import Validator from "../../db/Validator"; export default class MagicLinkAuthMethod implements AuthMethod { public constructor( @@ -75,6 +76,12 @@ export default class MagicLinkAuthMethod implements AuthMethod { const geo = geoip.lookup(req.ip); const actionType = isRegistration ? AuthMagicLinkActionType.REGISTER : AuthMagicLinkActionType.LOGIN; + if (isRegistration) { + await Validator.validate({ + email: new Validator().defined().unique(UserEmail, 'email'), + }, {email: email}); + } + await MagicLinkController.sendMagicLink( this.app, req.getSession().id,