From 15ef2dbf7808b0b5006fcec1f2e0cb8587f1aceb Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 5 Jan 2023 15:02:32 +0800 Subject: [PATCH] fix: rememberMe bug --- yudao-ui-admin-vue3/src/utils/auth.ts | 4 +++- .../src/views/Login/components/LoginForm.vue | 16 +++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/yudao-ui-admin-vue3/src/utils/auth.ts b/yudao-ui-admin-vue3/src/utils/auth.ts index de720346b..b55d676d5 100644 --- a/yudao-ui-admin-vue3/src/utils/auth.ts +++ b/yudao-ui-admin-vue3/src/utils/auth.ts @@ -47,7 +47,9 @@ export type LoginFormType = { export const getLoginForm = () => { const loginForm: LoginFormType = wsCache.get(LoginFormKey) - loginForm.password = decrypt(loginForm.password) as string + if (loginForm) { + loginForm.password = decrypt(loginForm.password) as string + } return loginForm } diff --git a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue index a2655f729..0953c0759 100644 --- a/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue +++ b/yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue @@ -215,13 +215,15 @@ const getTenantId = async () => { } // 记住我 const getCookie = () => { - const { username, password, rememberMe, tenantName } = authUtil.getLoginForm() - loginData.loginForm = { - ...loginData.loginForm, - username: username ? username : loginData.loginForm.username, - password: password ? password : loginData.loginForm.password, - rememberMe: rememberMe ? true : false, - tenantName: tenantName ? tenantName : loginData.loginForm.tenantName + const loginForm = authUtil.getLoginForm() + if (loginForm) { + loginData.loginForm = { + ...loginData.loginForm, + username: loginForm.username ? loginForm.username : loginData.loginForm.username, + password: loginForm.password ? loginForm.password : loginData.loginForm.password, + rememberMe: loginForm.rememberMe ? true : false, + tenantName: loginForm.tenantName ? loginForm.tenantName : loginData.loginForm.tenantName + } } } // 登录