fix(permission): 修复SSO重定向URL构造问题
- 正确处理路由中的查询参数 - 使用URLSearchParams构造查询字符串 - 对重定向URL进行编码以确保安全性 - 保持原有路径参数不变 - 提高SSO登录流程的稳定性
This commit is contained in:
@@ -102,10 +102,17 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
} else {
|
} else {
|
||||||
if(import.meta.env.VITE_DEFAULT_SSO =='true'){
|
if(import.meta.env.VITE_DEFAULT_SSO =='true'){
|
||||||
authUtil.setTenantId("1")
|
authUtil.setTenantId("1")
|
||||||
|
// 正确构造包含查询参数的重定向URL
|
||||||
|
let redirectUrl = to.fullPath;
|
||||||
|
if (Object.keys(to.query).length > 0) {
|
||||||
|
const queryParams = new URLSearchParams(to.query as Record<string, string>).toString();
|
||||||
|
redirectUrl = `${to.path}?${queryParams}`;
|
||||||
|
}
|
||||||
|
|
||||||
const redirectUri =
|
const redirectUri =
|
||||||
location.origin +
|
location.origin +
|
||||||
'/social-login?' +
|
'/social-login?' +
|
||||||
`type=100&redirect=${to.fullPath}`
|
`type=100&redirect=${encodeURIComponent(redirectUrl)}`
|
||||||
|
|
||||||
// 进行跳转
|
// 进行跳转
|
||||||
const res = await LoginApi.socialAuthRedirect(100, encodeURIComponent(redirectUri))
|
const res = await LoginApi.socialAuthRedirect(100, encodeURIComponent(redirectUri))
|
||||||
|
|||||||
Reference in New Issue
Block a user