Using local storage for token

This commit is contained in:
Peter KW 2024-03-18 00:42:05 +01:00
parent 24e7e68ea0
commit 8249678488

View file

@ -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) => {