delete unnecessary code

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2024-10-22 13:51:24 +02:00
parent 39e6432b05
commit 44e806cf1f
No known key found for this signature in database
2 changed files with 4 additions and 9 deletions

View file

@ -15,7 +15,7 @@ import {
samlLicensedAndEnabledMiddleware,
samlLicensedMiddleware,
} from '../middleware/saml-enabled-middleware';
import { isConnectionTestRequest, isSamlLicensedAndEnabled } from '../saml-helpers';
import { isSamlLicensedAndEnabled } from '../saml-helpers';
import { SamlService } from '../saml.service.ee';
import {
getServiceProviderConfigTestReturnUrl,
@ -111,10 +111,11 @@ export class SamlController {
res: express.Response,
binding: SamlLoginBinding,
) {
const isConnectionTestRequest = req.body.RelayState === getServiceProviderConfigTestReturnUrl();
try {
const loginResult = await this.samlService.handleSamlLogin(req, binding);
// if RelayState is set to the test connection Url, this is a test connection
if (isConnectionTestRequest(req)) {
if (isConnectionTestRequest) {
if (loginResult.authenticatedUser) {
return res.render('sso/saml-connection-test-success', loginResult.attributes);
} else {
@ -149,7 +150,7 @@ export class SamlController {
});
throw new AuthError('SAML Authentication failed');
} catch (error) {
if (isConnectionTestRequest(req)) {
if (isConnectionTestRequest) {
return res.render('sso/saml-connection-test-failed', { message: (error as Error).message });
}
this.eventService.emit('user-login-failed', {

View file

@ -13,8 +13,6 @@ import { License } from '@/license';
import { PasswordUtility } from '@/services/password.utility';
import { SAML_LOGIN_ENABLED, SAML_LOGIN_LABEL } from './constants';
import { getServiceProviderConfigTestReturnUrl } from './service-provider.ee';
import type { SamlConfiguration } from './types/requests';
import type { SamlAttributeMapping } from './types/saml-attribute-mapping';
import type { SamlPreferences } from './types/saml-preferences';
import type { SamlUserAttributes } from './types/saml-user-attributes';
@ -164,7 +162,3 @@ export function getMappedSamlAttributesFromFlowResult(
}
return result;
}
export function isConnectionTestRequest(req: SamlConfiguration.AcsRequest): boolean {
return req.body.RelayState === getServiceProviderConfigTestReturnUrl();
}