From aef4c2245d8d883de8730fef23beccfa56f729bd Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 23 Nov 2024 10:49:11 +0100 Subject: [PATCH] remove bogus file --- interface/authentication.ts | 54 ------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 interface/authentication.ts diff --git a/interface/authentication.ts b/interface/authentication.ts deleted file mode 100644 index 58f92024c..000000000 --- a/interface/authentication.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { Path } from 'react-router'; - -import type * as H from 'history'; -import { jwtDecode } from 'jwt-decode'; -import type { Me, SignInRequest, SignInResponse } from 'types'; - -import { ACCESS_TOKEN, alovaInstance } from '../../api/endpoints'; - -export const SIGN_IN_PATHNAME = 'loginPathname'; -export const SIGN_IN_SEARCH = 'loginSearch'; - -export const verifyAuthorization = () => - alovaInstance.Get('/rest/verifyAuthorization'); -export const signIn = (request: SignInRequest) => - alovaInstance.Post('/rest/signIn', request); - -export function getStorage() { - return localStorage || sessionStorage; -} - -export function storeLoginRedirect(location?: H.Location) { - if (location) { - getStorage().setItem(SIGN_IN_PATHNAME, location.pathname); - getStorage().setItem(SIGN_IN_SEARCH, location.search); - } -} - -export function clearLoginRedirect() { - getStorage().removeItem(SIGN_IN_PATHNAME); - getStorage().removeItem(SIGN_IN_SEARCH); -} - -export function fetchLoginRedirect(): Partial { - const signInPathname = getStorage().getItem(SIGN_IN_PATHNAME); - const signInSearch = getStorage().getItem(SIGN_IN_SEARCH); - clearLoginRedirect(); - return { - pathname: signInPathname || `/dashboard`, - search: (signInPathname && signInSearch) || undefined - }; -} - -export const clearAccessToken = () => localStorage.removeItem(ACCESS_TOKEN); -export const decodeMeJWT = (accessToken: string): Me => jwtDecode(accessToken); - -export function addAccessTokenParameter(url: string) { - const accessToken = getStorage().getItem(ACCESS_TOKEN); - if (!accessToken) { - return url; - } - const parsedUrl = new URL(url); - parsedUrl.searchParams.set(ACCESS_TOKEN, accessToken); - return parsedUrl.toString(); -}