-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refresh token on initial page load if expired, or logout (#257)
* feat: refresh token on initial page load if expired, or logout * chore: minor changes
- Loading branch information
Showing
5 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export interface Authentication { | ||
UserId: number | ||
SteamId: string | ||
AccessToken: string | ||
AccessExpiry: string | ||
RefreshToken: string | ||
RefreshExpiry: string | ||
UserId?: number | ||
SteamId?: string | ||
AccessToken?: string | ||
AccessExpiry?: string | ||
RefreshToken?: string | ||
RefreshExpiry?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import ky from 'ky' | ||
|
||
import type { Authentication } from '~/models/authentication' | ||
|
||
const api = ky.create({ | ||
prefixUrl: import.meta.env.PROD | ||
? 'https://auth.zeepkist-gtr.com/external/' | ||
: '/api/auth/external/' | ||
}) | ||
|
||
export const refresh = async (SteamId: string, RefreshToken: string) => { | ||
const response = await api.post('refresh', { | ||
json: { SteamId, RefreshToken } | ||
}) | ||
return response.json() as Promise<Authentication> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters