@@ -66,7 +112,7 @@
-
+
@@ -74,22 +120,17 @@
diff --git a/frontend/src/router/routes.ts b/frontend/src/router/routes.ts
index af5edf3..f7c6d02 100644
--- a/frontend/src/router/routes.ts
+++ b/frontend/src/router/routes.ts
@@ -26,6 +26,7 @@ const routes: RouteRecordRaw[] = [
{ path: 'right', component: () => import('pages/testRight.vue') },
{ path: 'domain', component: () => import('pages/TenantDomain.vue') },
{ path: 'userdomain', component: () => import('pages/UserDomain.vue')},
+ { path: 'user', component: () => import('pages/UserManagement.vue')},
{ path: 'condition', component: () => import('pages/conditionPage.vue') }
],
},
diff --git a/frontend/src/stores/useAuthStore.ts b/frontend/src/stores/useAuthStore.ts
index 16f6ffc..8887ddd 100644
--- a/frontend/src/stores/useAuthStore.ts
+++ b/frontend/src/stores/useAuthStore.ts
@@ -3,12 +3,20 @@ import { api } from 'boot/axios';
import { router } from 'src/router';
import { IDomainInfo } from '../types/ActionTypes';
import { jwtDecode } from 'jwt-decode';
+interface UserInfo {
+ firstName: string;
+ lastName: string;
+ email: string;
+}
+
export interface IUserState {
token?: string;
returnUrl: string;
currentDomain: IDomainInfo;
LeftDrawer: boolean;
userId?: string;
+ userInfo: UserInfo;
+ permissions: 'admin' | 'user';
}
export const useAuthStore = defineStore('auth', {
@@ -18,6 +26,8 @@ export const useAuthStore = defineStore('auth', {
LeftDrawer: false,
currentDomain: {} as IDomainInfo,
userId: '',
+ userInfo: {} as UserInfo,
+ permissions: 'user',
}),
getters: {
toggleLeftDrawer(): boolean {
@@ -36,9 +46,12 @@ export const useAuthStore = defineStore('auth', {
const result = await api.post(`api/token`, params);
console.info(result);
this.token = result.data.access_token;
- this.userId = jwtDecode(result.data.access_token).sub;
+ const tokenJson = jwtDecode(result.data.access_token);
+ this.userId = tokenJson.sub;
+ this.permissions = (tokenJson as any).permissions ?? 'user';
api.defaults.headers['Authorization'] = 'Bearer ' + this.token;
this.currentDomain = await this.getCurrentDomain();
+ this.userInfo = await this.getUserInfo();
router.push(this.returnUrl || '/');
return true;
} catch (e) {
@@ -63,6 +76,14 @@ export const useAuthStore = defineStore('auth', {
kintoneUrl: data.url,
}));
},
+ async getUserInfo():Promise{
+ const resp = (await api.get(`api/v1/users/me`)).data;
+ return {
+ firstName: resp.first_name,
+ lastName: resp.last_name,
+ email: resp.email,
+ }
+ },
logout() {
this.token = '';
this.currentDomain = {} as IDomainInfo; // 清空当前域