mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 17:14:05 -08:00
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
|
import { computed, reactive } from 'vue';
|
||
|
import { defineStore } from 'pinia';
|
||
|
import { EnterpriseEditionFeature } from '@/constants';
|
||
|
import { useRootStore } from '@/stores/n8nRootStore';
|
||
|
import { useSettingsStore } from '@/stores/settings';
|
||
|
import { initSSO } from '@/api/sso';
|
||
|
|
||
|
export const useSSOStore = defineStore('sso', () => {
|
||
|
const rootStore = useRootStore();
|
||
|
const settingsStore = useSettingsStore();
|
||
|
|
||
|
const state = reactive({
|
||
|
loading: false,
|
||
|
});
|
||
|
|
||
|
const isLoading = computed(() => state.loading);
|
||
|
|
||
|
const setLoading = (loading: boolean) => {
|
||
|
state.loading = loading;
|
||
|
};
|
||
|
|
||
|
const isSamlLoginEnabled = computed(() => settingsStore.isSamlLoginEnabled);
|
||
|
const isEnterpriseSamlEnabled = computed(() =>
|
||
|
settingsStore.isEnterpriseFeatureEnabled(EnterpriseEditionFeature.Saml),
|
||
|
);
|
||
|
const isDefaultAuthenticationSaml = computed(() => settingsStore.isDefaultAuthenticationSaml);
|
||
|
const showSsoLoginButton = computed(
|
||
|
() =>
|
||
|
isSamlLoginEnabled.value &&
|
||
|
isEnterpriseSamlEnabled.value &&
|
||
|
isDefaultAuthenticationSaml.value,
|
||
|
);
|
||
|
|
||
|
const getSSORedirectUrl = () => initSSO(rootStore.getRestApiContext);
|
||
|
|
||
|
return {
|
||
|
isLoading,
|
||
|
setLoading,
|
||
|
showSsoLoginButton,
|
||
|
getSSORedirectUrl,
|
||
|
};
|
||
|
});
|