Fix issue #48: "Remember me" checkbox on login
Some checks failed
Test / test (push) Failing after 2s
Some checks failed
Test / test (push) Failing after 2s
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { ref } from 'vue';
|
||||
import Server from './Server';
|
||||
import { GetToken, SetToken, ClearToken } from './TokenStore';
|
||||
|
||||
const UserStatus = ref(0);
|
||||
|
||||
@@ -7,8 +8,8 @@ function parseJwt(token) {
|
||||
return JSON.parse(atob(token.split('.')[1]));
|
||||
}
|
||||
|
||||
function SetUser(token){
|
||||
localStorage.setItem('token', token);
|
||||
function SetUser(token, remember){
|
||||
SetToken(token, remember);
|
||||
UserStatus.value = 1;
|
||||
}
|
||||
|
||||
@@ -33,7 +34,7 @@ async function GetUserSetting(key){
|
||||
}
|
||||
|
||||
function GetUser(){
|
||||
const token = localStorage.getItem('token');
|
||||
const token = GetToken();
|
||||
|
||||
if(token){
|
||||
const data = parseJwt(token);
|
||||
@@ -58,12 +59,11 @@ function IsAdmin(){
|
||||
}
|
||||
|
||||
function LoadUser(){
|
||||
const token = localStorage.getItem('token');
|
||||
if(token) UserStatus.value = 1;
|
||||
if(GetToken()) UserStatus.value = 1;
|
||||
}
|
||||
|
||||
function LogoutUser(){
|
||||
localStorage.removeItem("token");
|
||||
ClearToken();
|
||||
localStorage.removeItem("selectedCampaignId");
|
||||
UserStatus.value = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user