fix(editor): Redirect to home page after saving data on SAML onboarding page (no-changelog) (#5961)

fix(editor): redirect to home page after saving data on SAML onboarding page
This commit is contained in:
Csaba Tuncsik 2023-04-13 09:32:06 +02:00 committed by GitHub
parent 303521a0e2
commit 02ab1e7eef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View file

@ -68,6 +68,8 @@ export const useSSOStore = defineStore('sso', () => {
...params,
});
const userData = computed(() => usersStore.currentUser);
return {
isLoading,
setLoading,
@ -80,5 +82,6 @@ export const useSSOStore = defineStore('sso', () => {
saveSamlConfig,
testSamlConfig,
updateUser,
userData,
};
});

View file

@ -1,10 +1,14 @@
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import { useRouter } from 'vue-router/composables';
import { Notification } from 'element-ui';
import { IFormBoxConfig } from 'n8n-design-system';
import AuthView from '@/views/AuthView.vue';
import { i18n as locale } from '@/plugins/i18n';
import { useSSOStore } from '@/stores/sso';
import { VIEWS } from '@/constants';
const router = useRouter();
const ssoStore = useSSOStore();
const loading = ref(false);
@ -14,6 +18,7 @@ const FORM_CONFIG: IFormBoxConfig = reactive({
inputs: [
{
name: 'firstName',
initialValue: ssoStore.userData?.firstName,
properties: {
label: locale.baseText('auth.firstName'),
maxlength: 32,
@ -24,6 +29,7 @@ const FORM_CONFIG: IFormBoxConfig = reactive({
},
{
name: 'lastName',
initialValue: ssoStore.userData?.lastName,
properties: {
label: locale.baseText('auth.lastName'),
maxlength: 32,
@ -34,8 +40,19 @@ const FORM_CONFIG: IFormBoxConfig = reactive({
},
],
});
const onSubmit = (values: { firstName: string; lastName: string }) => {
ssoStore.updateUser(values);
const onSubmit = async (values: { firstName: string; lastName: string }) => {
try {
loading.value = true;
await ssoStore.updateUser(values);
await router.push({ name: VIEWS.HOMEPAGE });
} catch (error) {
loading.value = false;
Notification.error({
title: 'Error',
message: error.message,
position: 'bottom-right',
});
}
};
</script>