Skip to content

Commit

Permalink
fix: redirect to char selector if last char id is undefined
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Aug 27, 2024
1 parent 81d83c6 commit 86874fa
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const logger = useLogger('🔑 Auth');
export interface AuthState {
accessTokenExpiration: null | Date;
username: null | string;
lastCharID: number;
lastCharID: undefined | number;
activeChar: null | User;
loggingIn: boolean;
loginError: null | string;
Expand Down Expand Up @@ -93,14 +93,14 @@ export const useAuthStore = defineStore('auth', {
this.setPermissions([]);

try {
const call = getGRPCAuthClient().login({ username, password });
const call = getGRPCAuthClient().login({ username: username, password: password });
const { response } = await call;

this.loginStop(null);

this.username = username;

if (!response.char) {
if (response.char === undefined) {
logger.info('Login response without included char, redirecting to char selector');
this.setAccessTokenExpiration(toDate(response.expires));

Expand Down Expand Up @@ -154,6 +154,16 @@ export const useAuthStore = defineStore('auth', {
},
async chooseCharacter(charId?: number, redirect?: boolean): Promise<void> {
if (charId === undefined) {
if (!this.lastCharID) {
const route = useRoute();

await navigateTo({
name: 'auth-character-selector',
query: route.query,
});
return;
}

charId = this.lastCharID;
}

Expand Down

0 comments on commit 86874fa

Please sign in to comment.