增加密码强度提示,增加默认密码提示修改

main
yanzai 1 year ago
parent c197b836e8
commit 5904c3cba3

@ -11,7 +11,11 @@ class LoginService
$nowTime=date('Y-m-d H:i:s',time());
$result = array();
if(isset($arr['username']) and isset($arr['password'])){
if($arr['password']=='111111' or $arr['password']=='B123465a'){
$result['pwd_default']=true;
}else{
$result['pwd_default']=false;
}
$query=DB::table('users')->select('id','pwd','group')->where([['username','=',$arr['username']],['status','=',1],['lock_to','<',$nowTime]])->get();
if(count($query)==1){
// $hash = password_hash($arr['password'], PASSWORD_DEFAULT);

@ -91,8 +91,9 @@
} from "@/api/api.js";
import QRCode from 'qrcode'
import {
ElMessage
ElMessage, ElMessageBox
} from 'element-plus'
import {
ref
} from 'vue'
@ -128,12 +129,23 @@
Login(data).then(res => {
if (res.data.status == 'ok') {
sessionStorage.setItem('token', res.data.token);
sessionStorage.setItem('refreshToken', res.data.refresh_token);
// sessionStorage.setItem('tk', JSON.stringify(res.data.tk));
var token = sessionStorage.getItem('token');
if (token == res.data.token) {
window.location.href = "./#/dashboard"
if(res.data.pwd_default != undefined && res.data.pwd_default==true){
ElMessageBox.alert('请到"个人中心"修改您的密码', '提示', {
confirmButtonText: '知道了',
callback:action=> {
window.location.href = "./#/dashboard"
}
})
}else{
window.location.href = "./#/dashboard"
}
}
} else {
ElMessage.error(res.data.msg)

@ -62,9 +62,9 @@
<el-input size="large" v-model="oldpwd" type="password" placeholder="新密码"
style=" margin: auto 20px;" />
</el-form-item>
<el-form-item label="新密码">
<el-form-item label="新密码"><span v-if="strengthText" style="font-size: 12px;color:#999">{{strengthText}}</span>
<el-input size="large" v-model="newpwd" type="password" placeholder="新密码"
style=" margin: auto 20px;" />
style=" margin: auto 20px;" @input="checkPasswordStrength" />
</el-form-item>
<el-form-item label="再次输入">
<el-input size="large" v-model="renewpwd" type="password" placeholder="再次输入"
@ -336,8 +336,44 @@
})
}
}
const strengthText = ref('');
const checkPasswordStrength = (value) => {
let strength = 0;
if (value.length >= 8) strength++;
if (/[a-z]/.test(value)) strength++;
if (/[A-Z]/.test(value)) strength++;
if (/\d/.test(value)) strength++;
if (/[\W_]/.test(value)) strength++;
switch (strength) {
case 0:
strengthText.value = '无';
break;
case 1:
strengthText.value = '弱';
break;
case 2:
strengthText.value = '较弱';
break;
case 3:
strengthText.value = '中等';
break;
case 4:
strengthText.value = '较强';
break;
case 5:
strengthText.value = '强';
break;
default:
strengthText.value = '';
}
};
</script>
<style scoped>

Loading…
Cancel
Save