File tree Expand file tree Collapse file tree 3 files changed +14
-15
lines changed
Expand file tree Collapse file tree 3 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 2424 } from ' vue-final-modal' ;
2525
2626 import useSystemStore from ' @/bootstrap/stores/system.js' ;
27+ import useUserStore from ' ./bootstrap/stores/user' ;
28+
2729 import { useI18n } from ' vue-i18n' ;
2830 import { provideToast , useToast } from ' @/plugins/toast.js' ;
2931
3840 setup (props ) {
3941 const { t } = useI18n ();
4042 const systemStore = useSystemStore ();
43+ const userStore = useUserStore ();
4144
4245 // FETCH
4346
4952 // ON MOUNTED
5053 onMounted (async _ => {
5154 try {
52- await systemStore .checkAuthState ();
53- await systemStore .setUser ();
55+ await userStore .checkAuth ();
5456 } catch (e) {
5557 if (e .response .status == 401 ) {
5658 systemStore .setAppState (true );
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ import useUserStore from './user.js';
1212import {
1313 checkAccess ,
1414 fetchPreData ,
15- fetchUser ,
1615 searchConceptSelection ,
1716 uploadPlugin ,
1817 installPlugin ,
@@ -149,9 +148,6 @@ export const useSystemStore = defineStore('system', {
149148
150149 this . pluginStores [ id ] = defineStore ( `plugin_${ id } ` , store ) ;
151150 } ,
152- async checkAuthState ( ) {
153- return await fetchUser ( ) ;
154- } ,
155151 async checkAccess ( route ) {
156152 const accessResponse = await checkAccess ( route ) ;
157153 if ( accessResponse . status == 200 && accessResponse ?. data ?. redirect ) {
@@ -161,15 +157,6 @@ export const useSystemStore = defineStore('system', {
161157
162158 return true ;
163159 } ,
164- async setUser ( ) {
165- const userStore = useUserStore ( ) ;
166-
167- const userData = await fetchUser ( ) ;
168-
169- const loginSuccessful = userData . status == 'success' ;
170- userStore . setLoginState ( loginSuccessful ) ;
171- userStore . setActiveUser ( loginSuccessful ? userData . data : { } ) ;
172- } ,
173160 async initialize ( locale ) {
174161 resetState ( this ) ;
175162
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import {
1616 patchRoleData ,
1717 reactivateUser ,
1818 setUserAvatar ,
19+ fetchUser ,
1920} from '@/api.js' ;
2021
2122import {
@@ -137,6 +138,15 @@ export const useUserStore = defineStore('user', {
137138 } ,
138139 } ,
139140 actions : {
141+ async checkAuth ( ) {
142+ try {
143+ const user = await fetchUser ( )
144+ this . setActiveUser ( user )
145+ return user
146+ } catch {
147+ return null ;
148+ }
149+ } ,
140150 setLoginState ( value ) {
141151 this . userLoggedIn = value ;
142152 } ,
You can’t perform that action at this time.
0 commit comments