Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/components/auth/SsoLogin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ import { useStore } from 'vuex';
import { useI18n } from 'vue-i18n';
import FormComponent from './Form.vue';
import EntityImage from '../utils/EntityImage.vue';
import { SET_TOKENS } from '../../store/modules/user/actionTypes';
import { SET_TOKENS, FETCH_CURRENT_USER } from '../../store/modules/user/actionTypes';
import { FETCH_INITIAL_DATA } from '../../store/modules/app/actionTypes';
import { getCookie, removeCookie } from '../../utils';
import { API_ENDPOINT } from '../../api';
import { getSsoWorkspace } from '../../api/workspaces';
Expand Down Expand Up @@ -177,11 +178,24 @@ onMounted(async () => {
&& route.query.refresh_token
) {
try {
/**
* 1. Save tokens first
*/
await store.dispatch(SET_TOKENS, {
accessToken: route.query.access_token,
refreshToken: route.query.refresh_token,
});

/**
* 2. Load initial data (workspaces, projects) and user data
* This ensures that when components render after redirect,
* they have access to user data (e.g., for isAdmin checks)
*/
await Promise.all([
store.dispatch(FETCH_INITIAL_DATA),
store.dispatch(FETCH_CURRENT_USER),
]);

/**
* Determine redirect URL:
* 1. Use returnUrl from query params (provided by API after SSO)
Expand Down
Loading