fix some bugs
This commit is contained in:
+12
-5
@@ -1,4 +1,8 @@
|
||||
import { getTokenName } from '@/themeConfig'
|
||||
import {
|
||||
clearStoredAuthTokens,
|
||||
findStoredAuthToken,
|
||||
persistAuthToken,
|
||||
} from '@/utils/authToken'
|
||||
|
||||
import { ref } from 'vue'
|
||||
import {useConfigStore} from "@/store/configStore";
|
||||
@@ -11,7 +15,10 @@ const nameProject= getConfigApp('name')
|
||||
|
||||
|
||||
function setToken(token: string | undefined) {
|
||||
return localStorage.setItem(getTokenName(), token)
|
||||
if (!token) {
|
||||
return
|
||||
}
|
||||
return persistAuthToken(token)
|
||||
}
|
||||
|
||||
function setFingerPrint(val: string | undefined) {
|
||||
@@ -19,7 +26,7 @@ function setFingerPrint(val: string | undefined) {
|
||||
}
|
||||
|
||||
function getToken() {
|
||||
return localStorage.getItem(getTokenName())
|
||||
return findStoredAuthToken()
|
||||
}
|
||||
|
||||
function getIsActiveFingerprint() {
|
||||
@@ -56,7 +63,7 @@ export async function authenticateWithFingerprint() {
|
||||
const credentialId = btoa(String.fromCharCode(...new Uint8Array(credential.rawId)))
|
||||
|
||||
// بازیابی توکن از localStorage
|
||||
const token = localStorage.getItem(`${nameProject}_app_token`)
|
||||
const token = findStoredAuthToken()
|
||||
|
||||
if (!token) {
|
||||
console.warn('توکن پیدا نشد، عملیات متوقف شد.')
|
||||
@@ -78,7 +85,7 @@ export async function authenticateWithFingerprint() {
|
||||
|
||||
|
||||
function removeToken() {
|
||||
return localStorage.removeItem(getTokenName())
|
||||
return clearStoredAuthTokens()
|
||||
}
|
||||
|
||||
function removeFingerPrint() {
|
||||
|
||||
Reference in New Issue
Block a user