MagicLinkAuthMethod: do not allow register for already existing email
This commit is contained in:
parent
c08d03c8fb
commit
683fe7262b
@ -11,6 +11,7 @@ import RedirectBackComponent from "../../components/RedirectBackComponent";
|
|||||||
import Application from "../../Application";
|
import Application from "../../Application";
|
||||||
import {MailTemplate} from "../../mail/Mail";
|
import {MailTemplate} from "../../mail/Mail";
|
||||||
import AuthMagicLinkActionType from "./AuthMagicLinkActionType";
|
import AuthMagicLinkActionType from "./AuthMagicLinkActionType";
|
||||||
|
import Validator from "../../db/Validator";
|
||||||
|
|
||||||
export default class MagicLinkAuthMethod implements AuthMethod<MagicLink> {
|
export default class MagicLinkAuthMethod implements AuthMethod<MagicLink> {
|
||||||
public constructor(
|
public constructor(
|
||||||
@ -75,6 +76,12 @@ export default class MagicLinkAuthMethod implements AuthMethod<MagicLink> {
|
|||||||
const geo = geoip.lookup(req.ip);
|
const geo = geoip.lookup(req.ip);
|
||||||
const actionType = isRegistration ? AuthMagicLinkActionType.REGISTER : AuthMagicLinkActionType.LOGIN;
|
const actionType = isRegistration ? AuthMagicLinkActionType.REGISTER : AuthMagicLinkActionType.LOGIN;
|
||||||
|
|
||||||
|
if (isRegistration) {
|
||||||
|
await Validator.validate({
|
||||||
|
email: new Validator().defined().unique(UserEmail, 'email'),
|
||||||
|
}, {email: email});
|
||||||
|
}
|
||||||
|
|
||||||
await MagicLinkController.sendMagicLink(
|
await MagicLinkController.sendMagicLink(
|
||||||
this.app,
|
this.app,
|
||||||
req.getSession().id,
|
req.getSession().id,
|
||||||
|
Loading…
Reference in New Issue
Block a user