dev-audioprocessing/stores/user.js

38 lines
789 B
JavaScript
Raw Normal View History

2023-02-09 18:07:01 +00:00
// stores/counter.js
2023-02-25 06:48:20 +00:00
import { defineStore } from 'pinia';
2023-02-14 04:40:06 +00:00
export const useUserStore = defineStore('user', {
2023-02-09 18:07:01 +00:00
state: () => {
return {
user:{},
2023-02-14 04:40:06 +00:00
is_login:false,
token:''
2023-02-09 18:07:01 +00:00
}
},
// could also be defined as
// state: () => ({ count: 0 })
actions: {
2023-02-14 04:40:06 +00:00
login(user,token) {
2023-02-09 18:07:01 +00:00
this.user=user;
this.is_login=true;
2023-02-14 04:40:06 +00:00
this.token=token;
2023-02-09 18:07:01 +00:00
},
logout(){
this.user={}
this.is_login=false;
2023-02-25 06:48:20 +00:00
2023-02-15 03:36:51 +00:00
},
updateUser(user){
this.user=user;
2023-02-09 18:07:01 +00:00
}
},
2023-03-05 19:53:06 +00:00
getters:{
isAuthenticated(){
if (this.is_login===true){
return true;
}
return false;
}
},
2023-02-09 18:07:01 +00:00
persist: true,
2023-02-14 04:40:06 +00:00
})