add login
This commit is contained in:
1 parent
1ac9441a4d
commit
89e65f373f
19 files changed
+183
-28
No files matched your search
+32
-2
@@ -1,18 +1,48 @@
|
||||
import { createStore } from 'vuex';
|
||||
import { createStore, ActionContext } from 'vuex';
|
||||
|
||||
interface IUser {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IState {
|
||||
count: number;
|
||||
accessToken: string | undefined;
|
||||
refreshToken: string | undefined;
|
||||
user: IUser | undefined;
|
||||
}
|
||||
|
||||
const store = createStore({
|
||||
state(): IState {
|
||||
return {
|
||||
count: 0
|
||||
count: 0,
|
||||
accessToken: undefined,
|
||||
refreshToken: undefined,
|
||||
user: undefined
|
||||
};
|
||||
},
|
||||
mutations: {
|
||||
increment(state: IState) {
|
||||
state.count++;
|
||||
},
|
||||
setAccessToken(state: IState, payload: string) {
|
||||
state.accessToken = payload;
|
||||
},
|
||||
setRefreshToken(state: IState, payload: string) {
|
||||
state.refreshToken = payload;
|
||||
},
|
||||
setUser(state: IState, payload: IUser) {
|
||||
state.user = {
|
||||
...state.user,
|
||||
...payload
|
||||
};
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
setRefreshToken({ commit }: ActionContext<IState, IState>, payload: string) {
|
||||
commit('setRefreshToken', payload);
|
||||
},
|
||||
setAccessToken({ commit }: ActionContext<IState, IState>, payload: string) {
|
||||
commit('setAccessToken', payload);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user