Add JWT to login forms
This commit is contained in:
parent
47c1ecc9bc
commit
ad69193ac0
8 changed files with 93 additions and 6 deletions
28
resources/assets/scripts/store.js
Normal file
28
resources/assets/scripts/store.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
import User from './models/user';
|
||||
|
||||
export const storeData = {
|
||||
state: {
|
||||
user: null,
|
||||
},
|
||||
actions: {
|
||||
login: function ({ commit }) {
|
||||
commit('login');
|
||||
},
|
||||
logout: function ({ commit }) {
|
||||
commit('logout');
|
||||
},
|
||||
},
|
||||
getters: {
|
||||
user: function (state) {
|
||||
return state.user;
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
login: function (state) {
|
||||
state.user = new User().fromJwt(localStorage.getItem('token'));
|
||||
},
|
||||
logout: function (state) {
|
||||
state.user = null;
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue