mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -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;
|
||||
}
|
||||
setSamlLoginEnabled(prefs.loginEnabled ?? isSamlLoginEnabled());
|
||||
await setSamlLoginEnabled(prefs.loginEnabled ?? isSamlLoginEnabled());
|
||||
setSamlLoginLabel(prefs.loginLabel ?? getSamlLoginLabel());
|
||||
this.getIdentityProviderInstance(true);
|
||||
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
|
||||
export function setSamlLoginEnabled(enabled: boolean): void {
|
||||
export async function setSamlLoginEnabled(enabled: boolean): Promise<void> {
|
||||
if (enabled) {
|
||||
if (isEmailCurrentAuthenticationMethod()) {
|
||||
config.set(SAML_LOGIN_ENABLED, true);
|
||||
setCurrentAuthenticationMethod('saml');
|
||||
await setCurrentAuthenticationMethod('saml');
|
||||
}
|
||||
} else {
|
||||
config.set(SAML_LOGIN_ENABLED, false);
|
||||
setCurrentAuthenticationMethod('email');
|
||||
await setCurrentAuthenticationMethod('email');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import config from '@/config';
|
||||
import * as Db from '@/Db';
|
||||
import type { AuthProviderType } from '@/databases/entities/AuthIdentity';
|
||||
|
||||
export function isSamlCurrentAuthenticationMethod(): boolean {
|
||||
|
@ -17,6 +18,12 @@ export function doRedirectUsersFromLoginToSsoFlow(): boolean {
|
|||
return config.getEnv('sso.redirectLoginToSso');
|
||||
}
|
||||
|
||||
export function setCurrentAuthenticationMethod(authenticationMethod: AuthProviderType): void {
|
||||
export async function setCurrentAuthenticationMethod(
|
||||
authenticationMethod: AuthProviderType,
|
||||
): Promise<void> {
|
||||
config.set('userManagement.authenticationMethod', authenticationMethod);
|
||||
await Db.collections.Settings.save({
|
||||
key: 'userManagement.authenticationMethod',
|
||||
value: authenticationMethod,
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue