Browse Source

1、密码过期提示不强制修改

hella_online_20240911
bjang03 2 months ago
parent
commit
69377d6cd1
  1. 4
      src/api/system/password/index.ts
  2. 68
      src/views/login/components/LoginForm.vue

4
src/api/system/password/index.ts

@ -23,3 +23,7 @@ export const setConfig = (data: PassWordConfigVO) => {
export const getRuleList = () => { export const getRuleList = () => {
return request.get({ url: '/system/password/getRuleList'}) return request.get({ url: '/system/password/getRuleList'})
} }
// 验证密码是否过期
export const validateResetTime = (userId:number) => {
return request.get({ url: '/system/password/validateResetTime?userId=' + userId})
}

68
src/views/login/components/LoginForm.vue

@ -34,11 +34,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24" style="padding-right: 10px; padding-left: 10px" v-if="needCode"> <el-col :span="24" style="padding-right: 10px; padding-left: 10px" v-if="needCode">
<el-form-item prop="code">
<Verify ref="VerifySlide" captchaType="blockPuzzle" mode="" :imgSize="{ width: '450px', height: '225px' }" @success="capctchaCheckSuccess" @error="capctchaCheckError"></Verify>
</el-form-item>
</el-col>
<!-- <el-col :span="24" style="padding-right: 10px; padding-left: 10px" v-if="needCode">
<el-form-item prop="code"> <el-form-item prop="code">
<div class="flex w-[100%]"> <div class="flex w-[100%]">
<el-input v-model="loginData.loginForm.code" :placeholder="t('login.codePlaceholder')" <el-input v-model="loginData.loginForm.code" :placeholder="t('login.codePlaceholder')"
@ -52,7 +47,7 @@
</div> </div>
</div> </div>
</el-form-item> </el-form-item>
</el-col> --> </el-col>
<el-col :span="24" style="padding-right: 10px; padding-left: 10px; margin-top: -20px; margin-bottom: -20px"> <el-col :span="24" style="padding-right: 10px; padding-left: 10px; margin-top: -20px; margin-bottom: -20px">
<el-form-item> <el-form-item>
<el-row justify="space-between" style="width: 100%"> <el-row justify="space-between" style="width: 100%">
@ -75,6 +70,13 @@
@click="handleLogin()" /> @click="handleLogin()" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<!-- <Verify
ref="verify"
:captchaType="captchaType"
:imgSize="{ width: '400px', height: '200px' }"
mode="pop"
@success="handleLogin"
/> -->
</el-row> </el-row>
</el-form> </el-form>
</template> </template>
@ -82,13 +84,13 @@
import { ElLoading } from 'element-plus' import { ElLoading } from 'element-plus'
import LoginFormTitle from './LoginFormTitle.vue' import LoginFormTitle from './LoginFormTitle.vue'
import type { RouteLocationNormalizedLoaded } from 'vue-router' import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { Verify } from '@/components/Verifition'
import { useIcon } from '@/hooks/web/useIcon' import { useIcon } from '@/hooks/web/useIcon'
import * as authUtil from '@/utils/auth' import * as authUtil from '@/utils/auth'
import { usePermissionStore } from '@/store/modules/permission' import { usePermissionStore } from '@/store/modules/permission'
import * as LoginApi from '@/api/login' import * as LoginApi from '@/api/login'
import * as PassWordApi from '@/api/system/password'
import { LoginStateEnum, useFormValid, useLoginState } from './useLogin' import { LoginStateEnum, useFormValid, useLoginState } from './useLogin'
import { getCodeImg } from "@/api/login"; import { getCodeImg } from "@/api/login";
import router from "@/router"; import router from "@/router";
@ -96,6 +98,7 @@
import * as DeptApi from '@/api/system/dept' import * as DeptApi from '@/api/system/dept'
import { getTenant } from '@/utils/systemParam' import { getTenant } from '@/utils/systemParam'
import { getSystermUpdateAlert,getSystermUpdateUrl,getNeedCode } from '@/utils/systemParam' import { getSystermUpdateAlert,getSystermUpdateUrl,getNeedCode } from '@/utils/systemParam'
import {validateResetTime} from "@/api/system/password";
const needCode = ref(getNeedCode()==true||getNeedCode()=='true') const needCode = ref(getNeedCode()==true||getNeedCode()=='true')
defineOptions({ name: 'LoginForm' }) defineOptions({ name: 'LoginForm' })
@ -112,7 +115,8 @@
const permissionStore = usePermissionStore() const permissionStore = usePermissionStore()
const redirect = ref<string>('') const redirect = ref<string>('')
const loginLoading = ref(false) const loginLoading = ref(false)
const VerifySlide = ref() const verify = ref()
const captchaType = ref('blockPuzzle') // blockPuzzle clickWord
const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN) const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN)
@ -183,14 +187,13 @@
if(!needCode.value){ if(!needCode.value){
return return
} }
VerifySlide.value.refresh() getCodeImg().then(res => {
// getCodeImg().then(res => { captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled;
// captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled; if (captchaEnabled.value) {
// if (captchaEnabled.value) { codeUrl.value = "data:image/gif;base64," + res.img;
// codeUrl.value = "data:image/gif;base64," + res.img; loginData.loginForm.uuid = res.uuid;
// loginData.loginForm.uuid = res.uuid; }
// } });
// });
} }
//ID //ID
const getTenantId = async () => { const getTenantId = async () => {
@ -219,20 +222,9 @@
}) })
}; };
//
const capctchaCheckSuccess = ({captchaVerification})=>{
console.log('capctchaCheckSuccess',captchaVerification)
loginData.loginForm.code = captchaVerification
handleLogin()
}
//
const capctchaCheckError = ()=>{
VerifySlide.value.refresh()
}
const loading = ref() // ElLoading.service const loading = ref() // ElLoading.service
// //
const handleLogin = async () => { const handleLogin = async (params) => {
console.log('登录-185') console.log('登录-185')
if(getSystermUpdateAlert()=='true'||getSystermUpdateAlert()===true){ if(getSystermUpdateAlert()=='true'||getSystermUpdateAlert()===true){
await ElMessageBox.alert( await ElMessageBox.alert(
@ -257,6 +249,19 @@
}else{ }else{
res = await LoginApi.login(loginData.loginForm) res = await LoginApi.login(loginData.loginForm)
} }
try{
await PassWordApi.validateResetTime(res.userId)
}catch (e) {
if (e.code === 1002000010) {
await ElMessageBox.alert(
'<strong>密码长时间未修改,存在安全隐患,请及时修改</strong>',
'重要提示',
{
dangerouslyUseHTMLString: true,
}
)
}
}
if (!res) { if (!res) {
console.log('登录-195') console.log('登录-195')
getCode() getCode()
@ -286,12 +291,6 @@
// //
const { wsCache } = useCache() const { wsCache } = useCache()
wsCache.set(CACHE_KEY.DEPT, await DeptApi.getSimpleDeptList()) wsCache.set(CACHE_KEY.DEPT, await DeptApi.getSimpleDeptList())
}catch (e) {
if(e.code === 1002000010){
setTimeout(function (){
router.push({path:"/updatePasswordNewTips",query:{username:loginData.loginForm.username}})
},3000)
}
}finally { }finally {
console.log('登录-224') console.log('登录-224')
getCode() getCode()
@ -299,7 +298,6 @@
loading?.value?.close() loading?.value?.close()
} }
} }
// //
const doSocialLogin = async (type : number) => { const doSocialLogin = async (type : number) => {
if (type === 0) { if (type === 0) {

Loading…
Cancel
Save