-
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: added an additional layer of verification to check if the user …
…token is still active
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use server' | ||
|
||
import { ITokenUserInitialValues } from "@/interfaces/Generics" | ||
import { GetUserToken } from "@/utils/GetUserToken" | ||
|
||
export async function verifyUserToken() { | ||
|
||
try { | ||
const userParse: ITokenUserInitialValues = GetUserToken() | ||
|
||
const resp = await fetch(`${process.env.BACKEND_DOMAIN}/verify-token`, { | ||
method: "GET", | ||
headers: { | ||
Accept: "application/json", | ||
"Content-Type": "application/json", | ||
Authorization: "Bearer " + userParse.accessToken, | ||
} | ||
}) | ||
.then(async (value) => { | ||
|
||
if (value.status != 200) { | ||
return false | ||
} | ||
|
||
return true | ||
}) | ||
.catch((error) => { | ||
return false | ||
}) | ||
|
||
return resp | ||
} catch(err) { | ||
return false | ||
} | ||
|
||
} |
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