mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
fix(core): Persist CurrentAuthenticationMethod setting change (#5762)
* limit user invites when saml is enabled * persist CurrentAuthenticationMethod
This commit is contained in:
parent
57748b71e5
commit
4498c6013d
|
@ -210,7 +210,7 @@ export class SamlService {
|
||||||
}
|
}
|
||||||
this._samlPreferences.metadata = prefs.metadata;
|
this._samlPreferences.metadata = prefs.metadata;
|
||||||
}
|
}
|
||||||
setSamlLoginEnabled(prefs.loginEnabled ?? isSamlLoginEnabled());
|
await setSamlLoginEnabled(prefs.loginEnabled ?? isSamlLoginEnabled());
|
||||||
setSamlLoginLabel(prefs.loginLabel ?? getSamlLoginLabel());
|
setSamlLoginLabel(prefs.loginLabel ?? getSamlLoginLabel());
|
||||||
this.getIdentityProviderInstance(true);
|
this.getIdentityProviderInstance(true);
|
||||||
const result = await this.saveSamlPreferencesToDb();
|
const result = await this.saveSamlPreferencesToDb();
|
||||||
|
|
|
@ -28,15 +28,15 @@ export function getSamlLoginLabel(): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// can only toggle between email and saml, not directly to e.g. ldap
|
// can only toggle between email and saml, not directly to e.g. ldap
|
||||||
export function setSamlLoginEnabled(enabled: boolean): void {
|
export async function setSamlLoginEnabled(enabled: boolean): Promise<void> {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
if (isEmailCurrentAuthenticationMethod()) {
|
if (isEmailCurrentAuthenticationMethod()) {
|
||||||
config.set(SAML_LOGIN_ENABLED, true);
|
config.set(SAML_LOGIN_ENABLED, true);
|
||||||
setCurrentAuthenticationMethod('saml');
|
await setCurrentAuthenticationMethod('saml');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
config.set(SAML_LOGIN_ENABLED, false);
|
config.set(SAML_LOGIN_ENABLED, false);
|
||||||
setCurrentAuthenticationMethod('email');
|
await setCurrentAuthenticationMethod('email');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import config from '@/config';
|
import config from '@/config';
|
||||||
|
import * as Db from '@/Db';
|
||||||
import type { AuthProviderType } from '@/databases/entities/AuthIdentity';
|
import type { AuthProviderType } from '@/databases/entities/AuthIdentity';
|
||||||
|
|
||||||
export function isSamlCurrentAuthenticationMethod(): boolean {
|
export function isSamlCurrentAuthenticationMethod(): boolean {
|
||||||
|
@ -17,6 +18,12 @@ export function doRedirectUsersFromLoginToSsoFlow(): boolean {
|
||||||
return config.getEnv('sso.redirectLoginToSso');
|
return config.getEnv('sso.redirectLoginToSso');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setCurrentAuthenticationMethod(authenticationMethod: AuthProviderType): void {
|
export async function setCurrentAuthenticationMethod(
|
||||||
|
authenticationMethod: AuthProviderType,
|
||||||
|
): Promise<void> {
|
||||||
config.set('userManagement.authenticationMethod', authenticationMethod);
|
config.set('userManagement.authenticationMethod', authenticationMethod);
|
||||||
|
await Db.collections.Settings.save({
|
||||||
|
key: 'userManagement.authenticationMethod',
|
||||||
|
value: authenticationMethod,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue