refactor(core): Remove all legacy auth middleware code (no-changelog) (#8755)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-02-28 13:12:28 +01:00
committed by GitHub
parent 2e84684f04
commit 56c8791aff
37 changed files with 679 additions and 864 deletions

View File

@@ -2,11 +2,11 @@ import { Response } from 'express';
import { rateLimit } from 'express-rate-limit';
import validator from 'validator';
import { AuthService } from '@/auth/auth.service';
import { Get, Post, RestController } from '@/decorators';
import { PasswordUtility } from '@/services/password.utility';
import { UserManagementMailer } from '@/UserManagement/email';
import { PasswordResetRequest } from '@/requests';
import { issueCookie } from '@/auth/jwt';
import { isSamlCurrentAuthenticationMethod } from '@/sso/ssoHelpers';
import { UserService } from '@/services/user.service';
import { License } from '@/License';
@@ -36,6 +36,7 @@ export class PasswordResetController {
private readonly externalHooks: ExternalHooks,
private readonly internalHooks: InternalHooks,
private readonly mailer: UserManagementMailer,
private readonly authService: AuthService,
private readonly userService: UserService,
private readonly mfaService: MfaService,
private readonly urlService: UrlService,
@@ -114,7 +115,7 @@ export class PasswordResetController {
throw new UnprocessableRequestError('forgotPassword.ldapUserPasswordResetUnavailable');
}
const url = this.userService.generatePasswordResetUrl(user);
const url = this.authService.generatePasswordResetUrl(user);
const { id, firstName, lastName } = user;
try {
@@ -163,7 +164,7 @@ export class PasswordResetController {
throw new BadRequestError('');
}
const user = await this.userService.resolvePasswordResetToken(token);
const user = await this.authService.resolvePasswordResetToken(token);
if (!user) throw new NotFoundError('');
if (!user?.isOwner && !this.license.isWithinUsersLimit()) {
@@ -197,7 +198,7 @@ export class PasswordResetController {
const validPassword = this.passwordUtility.validate(password);
const user = await this.userService.resolvePasswordResetToken(token);
const user = await this.authService.resolvePasswordResetToken(token);
if (!user) throw new NotFoundError('');
if (user.mfaEnabled) {
@@ -216,7 +217,7 @@ export class PasswordResetController {
this.logger.info('User password updated successfully', { userId: user.id });
await issueCookie(res, user);
this.authService.issueCookie(res, user);
void this.internalHooks.onUserUpdate({
user,