File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import { go } from '@/router' ;
55import * as commands from '@/commands' ;
66import { handleError } from '@/lib/error' ;
7+ import { useUserStore } from '@/stores/user' ;
78import { Entity } from '@/core/entity/abstract' ;
89import { exit } from '@tauri-apps/plugin-process' ;
910
@@ -114,11 +115,12 @@ export async function leaveGame() {
114115 handleError ( err ) ;
115116 }
116117 finally {
117- if ( await commands . isLocal ( ) ) {
118- await go ( 'home' ) ;
118+ const { isAuthorizationTokenValid } = useUserStore ( ) ;
119+ if ( await commands . isRemote ( ) && await isAuthorizationTokenValid ( ) ) {
120+ await go ( 'lobby' ) ;
119121 }
120122 else {
121- await go ( 'lobby ' ) ;
123+ await go ( 'home ' ) ;
122124 }
123125 }
124126}
Original file line number Diff line number Diff line change @@ -8,6 +8,15 @@ import * as commands from '@/commands';
88export const useUserStore = defineStore ( 'user' , ( ) => {
99 const authorizationToken = ref < Option < string > > ( null ) ;
1010
11+ async function isAuthorizationTokenValid ( ) {
12+ if ( authorizationToken . value ) {
13+ return Boolean ( await commands . validateToken ( authorizationToken . value ) ) ;
14+ }
15+ else {
16+ return false ;
17+ }
18+ }
19+
1120 async function updateClient ( options : Partial < ClientOptions > = { } ) {
1221 await commands . updateClient ( {
1322 ...options ,
@@ -18,6 +27,7 @@ export const useUserStore = defineStore('user', () => {
1827
1928 return {
2029 authorizationToken,
30+ isAuthorizationTokenValid,
2131 updateClient,
2232 } ;
2333} ) ;
You can’t perform that action at this time.
0 commit comments