feat(系统设置): 认证登陆调试完成

This commit is contained in:
guoyuqi 2024-07-09 15:42:51 +08:00 committed by 刘瑞斌
parent 312e6dc8c5
commit 695f18fe47
3 changed files with 51 additions and 13 deletions

View File

@ -11,7 +11,7 @@ public class FilterChainUtils {
filterChainDefinitionMap.put("/login", "anon");
filterChainDefinitionMap.put("/ldap/login", "anon");
filterChainDefinitionMap.put("/authentication/get-list", "anon");
filterChainDefinitionMap.put("/authentication//get/by/type/**", "anon");
filterChainDefinitionMap.put("/authentication/get/by/type/**", "anon");
filterChainDefinitionMap.put("/we_com/info", "anon");
filterChainDefinitionMap.put("/ding_talk/info", "anon");
filterChainDefinitionMap.put("/lark/info", "anon");

View File

@ -205,6 +205,46 @@ const useUserStore = defineStore('user', {
return false;
}
},
async setUserInfoByAuth(pId: string, orgId: string) {
const appStore = useAppStore();
const router = useRouter();
const res = await userIsLogin();
this.setInfo(res);
appStore.setCurrentOrgId(orgId);
appStore.setCurrentProjectId(pId);
try {
const HasProjectPermission = await getUserHasProjectPermission(appStore.currentProjectId);
if (!HasProjectPermission) {
// 没有项目权限(用户所在的当前项目被禁用&用户被移除出去该项目)
router.push({
name: NO_PROJECT_ROUTE_NAME,
});
return;
}
const resp = await getProjectInfo(appStore.currentProjectId);
if (!resp) {
// 如果项目被删除或者被禁用,跳转到无项目页面
router.push({
name: NO_PROJECT_ROUTE_NAME,
});
}
if (resp) {
appStore.setCurrentMenuConfig(resp?.moduleIds || []);
}
} catch (err) {
appStore.setCurrentMenuConfig([]);
// eslint-disable-next-line no-console
console.log(err);
}
const { isLoginPage } = useUser();
if (isLoginPage()) {
// 当前页面为登录页面,且已经登录,跳转到首页
const currentRouteName = getFirstRouteNameByPermission(router.getRoutes());
router.push({ name: currentRouteName });
}
},
// 更新本地设置
updateLocalConfig(partial: Partial<UserState>) {
this.$patch(partial);

View File

@ -118,12 +118,13 @@
import { useRouter } from 'vue-router';
import { useStorage } from '@vueuse/core';
import { Message, SelectOptionData } from '@arco-design/web-vue';
import { partial } from 'lodash-es';
import TabQrCode from '@/views/login/components/tabQrCode.vue';
import { getProjectInfo } from '@/api/modules/project-management/basicInfo';
import { getAuthDetail, getAuthDetailByType } from '@/api/modules/setting/config';
import { getPlatformParamUrl } from '@/api/modules/user';
import { getPlatformParamUrl, isLogin as userIsLogin } from '@/api/modules/user';
import { GetLoginLogoUrl } from '@/api/requrls/setting/config';
import { useI18n } from '@/hooks/useI18n';
import useLoading from '@/hooks/useLoading';
@ -131,6 +132,7 @@
import { NO_PROJECT_ROUTE_NAME, NO_RESOURCE_ROUTE_NAME } from '@/router/constants';
import { useAppStore, useUserStore } from '@/store';
import useLicenseStore from '@/store/modules/setting/license';
import { UserState } from '@/store/modules/user/types';
import { encrypted } from '@/utils';
import { setLoginExpires, setToken } from '@/utils/auth';
import { getFirstRouteNameByPermission, routerNameHasPermission } from '@/utils/permission';
@ -366,15 +368,13 @@
//
const params = query.split('&');
// _token
let variableValue;
params.forEach((param) => {
const pair = param.split('=');
if (pair[0] === variable) {
console.log(pair[1]);
// eslint-disable-next-line prefer-destructuring
variableValue = pair[1];
const equalIndex = param.indexOf('=');
const variableName = param.substring(0, equalIndex);
if (variableName === variable) {
variableValue = param.substring(equalIndex + 1);
}
});
return variableValue;
@ -385,12 +385,10 @@
const TOKEN = getQueryVariable('_token');
const CSRF = getQueryVariable('_csrf');
const pId = getQueryVariable('_pId');
const orgId = getQueryVariable('orgId');
const orgId = getQueryVariable('_orgId');
if (TOKEN !== null && TOKEN !== undefined && CSRF !== null && CSRF !== undefined) {
setToken(TOKEN, CSRF);
appStore.setCurrentOrgId(pId || '');
appStore.setCurrentProjectId(orgId || '');
await userStore.checkIsLogin(true);
setToken(window.atob(TOKEN), CSRF);
await userStore.setUserInfoByAuth(pId || '', orgId || '');
}
}