Skip to content

Commit

Permalink
debug token handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Klesse committed Sep 4, 2024
1 parent 709826a commit f60ce46
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/runtime/composables/gql-mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { useAuth } from './use-auth';
export async function gqlMutation<T = any>(method: string, options: IGraphQLOptions = {}): Promise<{ data: T; error: Error }> {
const { $graphql, _meta } = useNuxtApp();
const _nuxtApp = useNuxtApp();
const { checkTokenAndRenew } = useAuth();
const { accessTokenState, refreshTokenState } = useAuthState();
const { checkTokenAndRenew } = useAuth();

// Check parameters
if (!method) {
Expand Down
9 changes: 2 additions & 7 deletions src/runtime/composables/use-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,12 @@ export function useAuth() {
return result;
}

async function checkTokenAndRenew(): Promise<{
refreshToken: string;
token: string;
} | null> {
async function checkTokenAndRenew() {
const { accessTokenState } = useAuthState();

if (isTokenExpired(accessTokenState.value)) {
return requestNewToken();
await requestNewToken();
}

return null;
}

function setTokens(newToken: string, newRefreshToken: string) {
Expand Down

0 comments on commit f60ce46

Please sign in to comment.