Added libs
This commit is contained in:
21
lockbox/vue/stores/auth.js
Normal file
21
lockbox/vue/stores/auth.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useAuthStore = defineStore('auth', {
|
||||
state: () => ({
|
||||
tokens: {},
|
||||
}),
|
||||
actions: {
|
||||
setToken(publicKey, token) {
|
||||
this.tokens[publicKey] = token
|
||||
localStorage.setItem(publicKey, token)
|
||||
},
|
||||
clearToken(publicKey) {
|
||||
this.tokens[publicKey] = null
|
||||
localStorage.removeItem(publicKey)
|
||||
},
|
||||
loadTokenFromStorage(publicKey) {
|
||||
const token = localStorage.getItem(publicKey)
|
||||
if (token) this.tokens[publicKey] = token
|
||||
}
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user