From 1ad39f386ebde61c75aa623d063c1b92b4810180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Thu, 15 Oct 2020 11:23:41 +0200 Subject: [PATCH] transfer to mac --- src/boot/axios.ts | 2 ++ src/plugins/user/models.ts | 4 +++ src/plugins/user/store/user.ts | 52 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 src/plugins/user/models.ts create mode 100644 src/plugins/user/store/user.ts diff --git a/src/boot/axios.ts b/src/boot/axios.ts index d8ed8d2..15375ba 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -11,3 +11,5 @@ export default boot(({ Vue }) => { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access Vue.prototype.$axios = axios; }); + +export { axios }; diff --git a/src/plugins/user/models.ts b/src/plugins/user/models.ts new file mode 100644 index 0000000..64149db --- /dev/null +++ b/src/plugins/user/models.ts @@ -0,0 +1,4 @@ +export interface LoginData { + userid: string; + password: string; +} diff --git a/src/plugins/user/store/user.ts b/src/plugins/user/store/user.ts new file mode 100644 index 0000000..54a0839 --- /dev/null +++ b/src/plugins/user/store/user.ts @@ -0,0 +1,52 @@ +import { Module, MutationTree, ActionTree, Commit } from 'vuex'; +import { StateInterface } from 'src/store'; +import { axios } from 'boot/axios'; +import { LoginData } from 'src/plugins/user/models' + +export interface Token { + browser: string; + expires: string; + lifetime: number; + platform: string; + token: string; +} + +export interface User { + display_name: string | null; + firstname: string; + lastname: string; + mail: string; + roles: string[]; +} + +export interface UserStateInterface { + permissions: string[]; + token: Token; + user: User; + userid: string; +} + +const state: UserStateInterface = { + permissions: [], + token: { browser: '', expires: '', lifetime: -1, platform: '', token: '' }, + user: { + display_name: '', + firstname: '', + lastname: '', + mail: '', + roles: [] + }, + userid: '' +}; + +const mutation: MutationTree = { + setState(state: UserStateInterface, data: UserStateInterface) { + state = data; + } +}; + +const actions: ActionTree = { + async = login({ commit: Commit }, data: LoginData) { + axios + } +};