Skip to content

Commit

Permalink
fix render issue
Browse files Browse the repository at this point in the history
  • Loading branch information
anbraten committed Aug 15, 2023
1 parent 59b7cea commit e12d434
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions composables/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import jwt_decode from 'jwt-decode';
import { browser } from 'process';

export const useAuth = () => {
const token = useCookie('token');
Expand All @@ -11,7 +10,6 @@ export const useAuth = () => {

function login(forgeId: number) {
window.location.href = `/api/auth/login?forgeId=${forgeId}`;

}

function logout() {
Expand All @@ -21,8 +19,8 @@ export const useAuth = () => {
if (token.value) {
const decodedToken = jwt_decode(token.value) as { userId: string; exp: number; iat: number };

// TODO: logout if token is expired
if (decodedToken.exp * 1000 < Date.now()) {
// TODO: logout if token is expired and we are in the browser => check if there is a better way
if (decodedToken.exp * 1000 < Date.now() && globalThis.window) {
logout();
}

Expand Down

0 comments on commit e12d434

Please sign in to comment.