Code formatting and cleanup

This commit is contained in:
Alice Gaudon 2020-09-06 10:47:24 +02:00
parent 25f890e082
commit b84c2cdff1
6 changed files with 1 additions and 16 deletions

View File

@ -8,7 +8,6 @@ import {MailTemplate} from "../../Mail";
import {AuthError, PendingApprovalAuthError, RegisterCallback} from "../AuthGuard"; import {AuthError, PendingApprovalAuthError, RegisterCallback} from "../AuthGuard";
import geoip from "geoip-lite"; import geoip from "geoip-lite";
import AuthController from "../AuthController"; import AuthController from "../AuthController";
import NunjucksComponent from "../../components/NunjucksComponent";
import RedirectBackComponent from "../../components/RedirectBackComponent"; import RedirectBackComponent from "../../components/RedirectBackComponent";

View File

@ -6,7 +6,6 @@ import Throttler from "../../Throttler";
import Mail, {MailTemplate} from "../../Mail"; import Mail, {MailTemplate} from "../../Mail";
import MagicLink from "../models/MagicLink"; import MagicLink from "../models/MagicLink";
import config from "config"; import config from "config";
import ModelFactory from "../../db/ModelFactory";
export default abstract class MagicLinkController extends Controller { export default abstract class MagicLinkController extends Controller {
public static async sendMagicLink(sessionID: string, actionType: string, original_url: string, email: string, mailTemplate: MailTemplate, data: object): Promise<void> { public static async sendMagicLink(sessionID: string, actionType: string, original_url: string, email: string, mailTemplate: MailTemplate, data: object): Promise<void> {

View File

@ -6,7 +6,6 @@ import User from "./User";
import argon2 from "argon2"; import argon2 from "argon2";
import {WhereTest} from "../../db/ModelQuery"; import {WhereTest} from "../../db/ModelQuery";
import UserEmail from "./UserEmail"; import UserEmail from "./UserEmail";
import ModelFactory from "../../db/ModelFactory";
import {EMAIL_REGEX} from "../../db/Validator"; import {EMAIL_REGEX} from "../../db/Validator";
export default class MagicLink extends Model implements AuthProof<User> { export default class MagicLink extends Model implements AuthProof<User> {
@ -35,10 +34,6 @@ export default class MagicLink extends Model implements AuthProof<User> {
private generated_at?: Date = undefined; private generated_at?: Date = undefined;
private authorized: boolean = false; private authorized: boolean = false;
constructor(factory: ModelFactory<MagicLink>) {
super(factory);
}
protected init(): void { protected init(): void {
this.setValidation('session_id').defined().length(32).unique(this); this.setValidation('session_id').defined().length(32).unique(this);
this.setValidation('email').defined().regexp(EMAIL_REGEX); this.setValidation('email').defined().regexp(EMAIL_REGEX);

View File

@ -25,10 +25,6 @@ export default class User extends Model {
public readonly mainEmail = this.emails.cloneReduceToOne().constraint(q => q.where('id', this.main_email_id)); public readonly mainEmail = this.emails.cloneReduceToOne().constraint(q => q.where('id', this.main_email_id));
public constructor(factory: ModelFactory<User>) {
super(factory);
}
protected init(): void { protected init(): void {
this.setValidation('name').acceptUndefined().between(3, 64); this.setValidation('name').acceptUndefined().between(3, 64);
this.setValidation('main_email_id').acceptUndefined().exists(UserEmail, 'id'); this.setValidation('main_email_id').acceptUndefined().exists(UserEmail, 'id');

View File

@ -15,10 +15,6 @@ export default class UserEmail extends Model {
foreignKey: 'id' foreignKey: 'id'
}); });
constructor(factory: ModelFactory<UserEmail>) {
super(factory);
}
protected init(): void { protected init(): void {
this.setValidation('user_id').acceptUndefined().exists(User, 'id'); this.setValidation('user_id').acceptUndefined().exists(User, 'id');
this.setValidation('email').defined().regexp(EMAIL_REGEX).unique(this); this.setValidation('email').defined().regexp(EMAIL_REGEX).unique(this);