refactor(core): Make controller constructors consistent (no-changelog) (#7015)

This commit is contained in:
Iván Ovejero
2023-08-25 13:23:22 +02:00
committed by GitHub
parent 07d3633a05
commit 87cf1d9c1b
10 changed files with 145 additions and 270 deletions

View File

@@ -13,13 +13,13 @@ import {
hashPassword,
validatePassword,
} from '@/UserManagement/UserManagementHelper';
import type { UserManagementMailer } from '@/UserManagement/email';
import { UserManagementMailer } from '@/UserManagement/email';
import { Response } from 'express';
import type { ILogger } from 'n8n-workflow';
import type { Config } from '@/config';
import { ILogger } from 'n8n-workflow';
import { Config } from '@/config';
import { PasswordResetRequest } from '@/requests';
import type { IExternalHooksClass, IInternalHooksClass } from '@/Interfaces';
import { IExternalHooksClass, IInternalHooksClass } from '@/Interfaces';
import { issueCookie } from '@/auth/jwt';
import { isLdapEnabled } from '@/Ldap/helpers';
import { isSamlCurrentAuthenticationMethod } from '@/sso/ssoHelpers';
@@ -30,50 +30,20 @@ import { RESPONSE_ERROR_MESSAGES } from '@/constants';
import { TokenExpiredError } from 'jsonwebtoken';
import type { JwtPayload } from '@/services/jwt.service';
import { JwtService } from '@/services/jwt.service';
import type { MfaService } from '@/Mfa/mfa.service';
import { MfaService } from '@/Mfa/mfa.service';
@RestController()
export class PasswordResetController {
private readonly config: Config;
private readonly logger: ILogger;
private readonly externalHooks: IExternalHooksClass;
private readonly internalHooks: IInternalHooksClass;
private readonly mailer: UserManagementMailer;
private readonly jwtService: JwtService;
private readonly userService: UserService;
private readonly mfaService: MfaService;
constructor({
config,
logger,
externalHooks,
internalHooks,
mailer,
mfaService,
}: {
config: Config;
logger: ILogger;
externalHooks: IExternalHooksClass;
internalHooks: IInternalHooksClass;
mailer: UserManagementMailer;
mfaService: MfaService;
}) {
this.config = config;
this.logger = logger;
this.externalHooks = externalHooks;
this.internalHooks = internalHooks;
this.mailer = mailer;
this.jwtService = Container.get(JwtService);
this.userService = Container.get(UserService);
this.mfaService = mfaService;
}
constructor(
private readonly config: Config,
private readonly logger: ILogger,
private readonly externalHooks: IExternalHooksClass,
private readonly internalHooks: IInternalHooksClass,
private readonly mailer: UserManagementMailer,
private readonly userService: UserService,
private readonly jwtService: JwtService,
private readonly mfaService: MfaService,
) {}
/**
* Send a password reset email.