密码清理

main
liutao 4 days ago
parent ad5f5bb7dc
commit aa6061d366

@ -1,6 +1,5 @@
import { useCache, CACHE_KEY } from '@/hooks/web/useCache'
import { TokenType } from '@/api/login/types'
import { decrypt, encrypt } from '@/utils/jsencrypt'
const { wsCache } = useCache()
@ -47,14 +46,19 @@ export type LoginFormType = {
export const getLoginForm = () => {
const loginForm: LoginFormType = wsCache.get(CACHE_KEY.LoginForm)
if (loginForm) {
loginForm.password = decrypt(loginForm.password) as string
// Never restore a password from browser storage. Also sanitize legacy cache entries.
loginForm.password = ''
wsCache.set(CACHE_KEY.LoginForm, loginForm, { exp: 30 * 24 * 60 * 60 })
}
return loginForm
}
export const setLoginForm = (loginForm: LoginFormType) => {
loginForm.password = encrypt(loginForm.password) as string
wsCache.set(CACHE_KEY.LoginForm, loginForm, { exp: 30 * 24 * 60 * 60 })
wsCache.set(
CACHE_KEY.LoginForm,
{ ...loginForm, password: '' },
{ exp: 30 * 24 * 60 * 60 }
)
}
export const removeLoginForm = () => {

@ -58,6 +58,7 @@
label-position="top"
label-width="120px"
size="large"
autocomplete="off"
>
<el-row style="margin-right: -10px; margin-left: -10px">
<el-col :span="24" style="padding-right: 10px; padding-left: 10px">
@ -80,6 +81,7 @@
<el-form-item prop="username">
<el-input
v-model="loginData.loginForm.username"
autocomplete="off"
:placeholder="t('login.usernamePlaceholder')"
:prefix-icon="iconAvatar"
/>
@ -89,6 +91,7 @@
<el-form-item prop="password">
<el-input
v-model="loginData.loginForm.password"
autocomplete="new-password"
:placeholder="t('login.passwordPlaceholder')"
:prefix-icon="iconLock"
show-password
@ -199,8 +202,8 @@ const loginData = reactive({
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE !== 'false',
loginForm: {
tenantName: '内蒙必硕',
username: 'admin',
password: 'admin123',
username: '',
password: '',
captchaVerification: '',
rememberMe: false
}

@ -8,6 +8,7 @@
label-position="top"
label-width="120px"
size="large"
autocomplete="off"
>
<el-row style="margin-right: -10px; margin-left: -10px">
<el-col :span="24" style="padding-right: 10px; padding-left: 10px">
@ -31,6 +32,7 @@
<el-form-item prop="username">
<el-input
v-model="loginData.loginForm.username"
autocomplete="off"
:placeholder="t('login.usernamePlaceholder')"
:prefix-icon="iconAvatar"
/>
@ -40,6 +42,7 @@
<el-form-item prop="password">
<el-input
v-model="loginData.loginForm.password"
autocomplete="new-password"
:placeholder="t('login.passwordPlaceholder')"
:prefix-icon="iconLock"
show-password
@ -173,10 +176,10 @@ const loginData = reactive({
tenantEnable: import.meta.env.VITE_APP_TENANT_ENABLE,
loginForm: {
tenantName: defaultTenantName,
username: import.meta.env.VITE_APP_DEFAULT_LOGIN_USERNAME || '',
password: import.meta.env.VITE_APP_DEFAULT_LOGIN_PASSWORD || '',
username: '',
password: '',
captchaVerification: '',
rememberMe: true //
rememberMe: false
}
})

Loading…
Cancel
Save