mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add logout feature in dashboard
This commit is contained in:
parent
6aa849b305
commit
259007afa5
2 changed files with 44 additions and 10 deletions
|
|
@ -29,6 +29,26 @@ export async function loginAndGetToken(username: string, password: string): Prom
|
|||
return response;
|
||||
}
|
||||
|
||||
export async function logout(): Promise<any> {
|
||||
// Request Config
|
||||
|
||||
// get origin
|
||||
const HeadersConfig = new Headers({ "Content-Type": "application/x-www-form-urlencoded" });
|
||||
const urlencoded = new URLSearchParams();
|
||||
|
||||
const requestOptions: any = {
|
||||
method: "DELETE",
|
||||
headers: HeadersConfig,
|
||||
body: urlencoded,
|
||||
redirect: "follow",
|
||||
credentials: "include",
|
||||
};
|
||||
|
||||
// fetch using await and async
|
||||
const response = await fetch(`${getAPIUrl()}auth/logout`, requestOptions);
|
||||
return response;
|
||||
}
|
||||
|
||||
export async function getUserInfo(token: string): Promise<any> {
|
||||
const origin = window.location.origin;
|
||||
const HeadersConfig = new Headers({ Authorization: `Bearer ${token}`, Origin: origin });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue