Using local storage for token
This commit is contained in:
parent
24e7e68ea0
commit
8249678488
1 changed files with 4 additions and 0 deletions
|
@ -15,12 +15,16 @@ function LoginCheck(props: {
|
||||||
username: props.username,
|
username: props.username,
|
||||||
password: props.password,
|
password: props.password,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
localStorage.clear();
|
||||||
|
|
||||||
api
|
api
|
||||||
.login(user)
|
.login(user)
|
||||||
.then((response: APIResponse<string>) => {
|
.then((response: APIResponse<string>) => {
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
if (response.data !== undefined) {
|
if (response.data !== undefined) {
|
||||||
const token = response.data;
|
const token = response.data;
|
||||||
|
localStorage.setItem("accessToken", token);
|
||||||
//TODO: change so that it checks for user type (admin, user, pm) instead
|
//TODO: change so that it checks for user type (admin, user, pm) instead
|
||||||
if (token !== "" && props.username === "admin") {
|
if (token !== "" && props.username === "admin") {
|
||||||
props.setAuthority((prevAuth) => {
|
props.setAuthority((prevAuth) => {
|
||||||
|
|
Loading…
Reference in a new issue