diff --git a/src/api/system/password/index.ts b/src/api/system/password/index.ts index cc2495169..9f07574cc 100644 --- a/src/api/system/password/index.ts +++ b/src/api/system/password/index.ts @@ -23,3 +23,7 @@ export const setConfig = (data: PassWordConfigVO) => { export const getRuleList = () => { return request.get({ url: '/system/password/getRuleList'}) } +// 验证密码是否过期 +export const validateResetTime = (userId:number) => { + return request.get({ url: '/system/password/validateResetTime?userId=' + userId}) +} diff --git a/src/views/login/components/LoginForm.vue b/src/views/login/components/LoginForm.vue index f9b31784c..a6f47e85c 100644 --- a/src/views/login/components/LoginForm.vue +++ b/src/views/login/components/LoginForm.vue @@ -34,11 +34,6 @@ - - - - - + @@ -75,6 +70,13 @@ @click="handleLogin()" /> + @@ -82,13 +84,13 @@ import { ElLoading } from 'element-plus' import LoginFormTitle from './LoginFormTitle.vue' import type { RouteLocationNormalizedLoaded } from 'vue-router' - import { Verify } from '@/components/Verifition' import { useIcon } from '@/hooks/web/useIcon' import * as authUtil from '@/utils/auth' import { usePermissionStore } from '@/store/modules/permission' import * as LoginApi from '@/api/login' + import * as PassWordApi from '@/api/system/password' import { LoginStateEnum, useFormValid, useLoginState } from './useLogin' import { getCodeImg } from "@/api/login"; import router from "@/router"; @@ -96,6 +98,7 @@ import * as DeptApi from '@/api/system/dept' import { getTenant } from '@/utils/systemParam' import { getSystermUpdateAlert,getSystermUpdateUrl,getNeedCode } from '@/utils/systemParam' + import {validateResetTime} from "@/api/system/password"; const needCode = ref(getNeedCode()==true||getNeedCode()=='true') defineOptions({ name: 'LoginForm' }) @@ -112,7 +115,8 @@ const permissionStore = usePermissionStore() const redirect = ref('') const loginLoading = ref(false) - const VerifySlide = ref() + const verify = ref() + const captchaType = ref('blockPuzzle') // blockPuzzle 滑块 clickWord 点击文字 const getShow = computed(() => unref(getLoginState) === LoginStateEnum.LOGIN) @@ -183,14 +187,13 @@ if(!needCode.value){ return } - VerifySlide.value.refresh() - // getCodeImg().then(res => { - // captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled; - // if (captchaEnabled.value) { - // codeUrl.value = "data:image/gif;base64," + res.img; - // loginData.loginForm.uuid = res.uuid; - // } - // }); + getCodeImg().then(res => { + captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled; + if (captchaEnabled.value) { + codeUrl.value = "data:image/gif;base64," + res.img; + loginData.loginForm.uuid = res.uuid; + } + }); } //获取租户ID 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 handleLogin = async () => { + const handleLogin = async (params) => { console.log('登录-185') if(getSystermUpdateAlert()=='true'||getSystermUpdateAlert()===true){ await ElMessageBox.alert( @@ -257,6 +249,19 @@ }else{ res = await LoginApi.login(loginData.loginForm) } + try{ + await PassWordApi.validateResetTime(res.userId) + }catch (e) { + if (e.code === 1002000010) { + await ElMessageBox.alert( + '密码长时间未修改,存在安全隐患,请及时修改', + '重要提示', + { + dangerouslyUseHTMLString: true, + } + ) + } + } if (!res) { console.log('登录-195') getCode() @@ -286,20 +291,13 @@ // 存储 部门信息 const { wsCache } = useCache() 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') getCode() loginLoading.value = false loading?.value?.close() } } - // 社交登录 const doSocialLogin = async (type : number) => { if (type === 0) {