refactor(core): Use Dependency Injection for all Controller classes (no-changelog) (#8146)

## Review / Merge checklist
- [x] PR title and summary are descriptive
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-12-27 11:50:43 +01:00
committed by GitHub
parent 518a99e528
commit f69ddcd796
51 changed files with 209 additions and 522 deletions

View File

@@ -1,5 +1,4 @@
import express from 'express';
import { Container, Service } from 'typedi';
import {
Authorized,
Get,
@@ -36,13 +35,13 @@ import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import { AuthError } from '@/errors/response-errors/auth.error';
import { UrlService } from '@/services/url.service';
@Service()
@Authorized()
@RestController('/sso/saml')
export class SamlController {
constructor(
private readonly samlService: SamlService,
private readonly urlService: UrlService,
private readonly internalHooks: InternalHooks,
) {}
@NoAuthRequired()
@@ -142,7 +141,7 @@ export class SamlController {
}
}
if (loginResult.authenticatedUser) {
void Container.get(InternalHooks).onUserLoginSuccess({
void this.internalHooks.onUserLoginSuccess({
user: loginResult.authenticatedUser,
authenticationMethod: 'saml',
});
@@ -159,7 +158,7 @@ export class SamlController {
return res.status(202).send(loginResult.attributes);
}
}
void Container.get(InternalHooks).onUserLoginFailed({
void this.internalHooks.onUserLoginFailed({
user: loginResult.attributes.email ?? 'unknown',
authenticationMethod: 'saml',
});
@@ -168,7 +167,7 @@ export class SamlController {
if (isConnectionTestRequest(req)) {
return res.send(getSamlConnectionTestFailedView((error as Error).message));
}
void Container.get(InternalHooks).onUserLoginFailed({
void this.internalHooks.onUserLoginFailed({
user: 'unknown',
authenticationMethod: 'saml',
});