mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-06 17:08:29 +08:00
#IB8ZT6 认证平台无法修改密码
This commit is contained in:
parent
a1a9fab6d6
commit
5bde3eafff
@ -16,14 +16,14 @@
|
||||
|
||||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, Inject } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { I18NService } from '@core';
|
||||
import { SettingsService, User, ALAIN_I18N_TOKEN } from '@delon/theme';
|
||||
import { NzMessageService } from 'ng-zorro-antd/message';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { ChangePassword } from '../../../entity/ChangePassword';
|
||||
import { PasswordService } from '../../../service/password.service';
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-password',
|
||||
templateUrl: './password.component.html',
|
||||
@ -39,10 +39,10 @@ export class PasswordComponent implements OnInit {
|
||||
};
|
||||
validateForm!: FormGroup;
|
||||
oldPasswordVisible = false;
|
||||
policy:any = {};
|
||||
policy: any = {};
|
||||
passwordVisible = false;
|
||||
policyMessage:any[] =[];
|
||||
dynamicallyCheckPasswordErrorMsg = "";
|
||||
policyMessage: any[] = [];
|
||||
dynamicallyCheckPasswordErrorMsg = '';
|
||||
constructor(
|
||||
private router: Router,
|
||||
private fb: FormBuilder,
|
||||
@ -51,14 +51,14 @@ export class PasswordComponent implements OnInit {
|
||||
private msg: NzMessageService,
|
||||
@Inject(ALAIN_I18N_TOKEN) private i18n: I18NService,
|
||||
private cdr: ChangeDetectorRef
|
||||
) { }
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.loadPolicy();
|
||||
this.validateForm = this.fb.group({
|
||||
oldPassword: [null, [Validators.required]],
|
||||
confirmPassword: [null, [Validators.required]],
|
||||
password: [null, [Validators.required]],
|
||||
password: [null, [Validators.required]]
|
||||
});
|
||||
|
||||
let user: any = this.settingsService.user;
|
||||
@ -69,27 +69,26 @@ export class PasswordComponent implements OnInit {
|
||||
this.cdr.detectChanges();
|
||||
}
|
||||
|
||||
|
||||
loadPolicy():void {
|
||||
this.policyMessage=[];
|
||||
loadPolicy(): void {
|
||||
this.policyMessage = [];
|
||||
this.passwordService.passwordpolicy().subscribe(res => {
|
||||
if(res.code == 0) {
|
||||
if (res.code == 0) {
|
||||
let data = res.data;
|
||||
this.policy = data;
|
||||
this.policyMessage=res.data.policMessageList;
|
||||
this.policyMessage = res.data.policMessageList;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dynamicallyCheckConfirm(value:any):void {
|
||||
dynamicallyCheckConfirm(value: any): void {
|
||||
if (value != this.form.model.password) {
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.twice')
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.twice');
|
||||
} else {
|
||||
this.dynamicallyCheckPasswordErrorMsg = '';
|
||||
}
|
||||
}
|
||||
|
||||
dynamicallyCheckPassword(value:any):void {
|
||||
dynamicallyCheckPassword(value: any): void {
|
||||
if (value == '') {
|
||||
this.dynamicallyCheckPasswordErrorMsg = '';
|
||||
return;
|
||||
@ -99,78 +98,76 @@ export class PasswordComponent implements OnInit {
|
||||
let inputLength = value.length;
|
||||
if (inputLength < data.minLength || inputLength > data.maxLength) {
|
||||
//this.dynamicallyCheckPasswordErrorMsg = "限定新密码长度为"+data.minLength+"-"+data.maxLength+"位"
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength')
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.lowerCase > 0) {
|
||||
let strArr = Array.from(value)
|
||||
let abc:any = [];
|
||||
strArr.forEach(function (value:any, index, array) {
|
||||
let code = value.charCodeAt()
|
||||
let strArr = Array.from(value);
|
||||
let abc: any = [];
|
||||
strArr.forEach(function (value: any, index, array) {
|
||||
let code = value.charCodeAt();
|
||||
if (code >= 'a'.charCodeAt(0) && code <= 'z'.charCodeAt(0)) {
|
||||
abc.push(value)
|
||||
abc.push(value);
|
||||
}
|
||||
})
|
||||
if(abc.length < data.lowerCase) {
|
||||
});
|
||||
if (abc.length < data.lowerCase) {
|
||||
//this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.lowerCase+"位【a-z】小写字母"
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength')
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(data.upperCase > 0) {
|
||||
let strArr = Array.from(value)
|
||||
let ABC:any = [];
|
||||
strArr.forEach(function (value:any, index, array) {
|
||||
let code = value.charCodeAt()
|
||||
if (data.upperCase > 0) {
|
||||
let strArr = Array.from(value);
|
||||
let ABC: any = [];
|
||||
strArr.forEach(function (value: any, index, array) {
|
||||
let code = value.charCodeAt();
|
||||
if (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0)) {
|
||||
ABC.push(value)
|
||||
ABC.push(value);
|
||||
}
|
||||
})
|
||||
if(ABC.length < data.upperCase) {
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength')
|
||||
});
|
||||
if (ABC.length < data.upperCase) {
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength');
|
||||
//this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.lowerCase+"位【A-Z】大写字母"
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.digits > 0) {
|
||||
let strArr = Array.from(value)
|
||||
let number:any = [];
|
||||
strArr.forEach(function (value:any, index, array) {
|
||||
let strArr = Array.from(value);
|
||||
let number: any = [];
|
||||
strArr.forEach(function (value: any, index, array) {
|
||||
var regPos = /^[0-9]+.?[0-9]*/; //判断是否是数字。
|
||||
if(regPos.test(value) ){
|
||||
number.push(value)
|
||||
if (regPos.test(value)) {
|
||||
number.push(value);
|
||||
}
|
||||
})
|
||||
if(number.length < data.digits) {
|
||||
});
|
||||
if (number.length < data.digits) {
|
||||
//this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.digits+"位【0-9】阿拉伯数字";
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength')
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(data.specialChar > 0) {
|
||||
var AllNumIsSame = new Array("’","”","!","@","#","$","%","^","&","*",".");
|
||||
let strArr = Array.from(value)
|
||||
let number:any = [];
|
||||
strArr.forEach(function (value:any, index, array) {
|
||||
if(AllNumIsSame.indexOf(value) != -1){//$.type 是jquery的函数,用来判断对象类型
|
||||
number.push(value)
|
||||
if (data.specialChar > 0) {
|
||||
var AllNumIsSame = new Array('’', '”', '!', '@', '#', '$', '%', '^', '&', '*', '.');
|
||||
let strArr = Array.from(value);
|
||||
let number: any = [];
|
||||
strArr.forEach(function (value: any, index, array) {
|
||||
if (AllNumIsSame.indexOf(value) != -1) {
|
||||
//$.type 是jquery的函数,用来判断对象类型
|
||||
number.push(value);
|
||||
}
|
||||
})
|
||||
if(number.length < data.specialChar) {
|
||||
});
|
||||
if (number.length < data.specialChar) {
|
||||
//this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.specialChar+"位特殊字符";
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength')
|
||||
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.non-conformance-strength');
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.dynamicallyCheckPasswordErrorMsg = '';
|
||||
|
||||
}
|
||||
|
||||
onSubmit(): void {
|
||||
@ -182,18 +179,15 @@ export class PasswordComponent implements OnInit {
|
||||
if (res.code == 0) {
|
||||
this.form.model.init(res.data);
|
||||
this.msg.success(this.i18n.fanyi('mxk.alert.operate.success'));
|
||||
this.form.model.password = '';
|
||||
this.form.model.oldPassword = '';
|
||||
this.form.model.confirmPassword = '';
|
||||
//设置密码正常,路由不进行拦截
|
||||
let user = this.settingsService.user;
|
||||
user['passwordSetType'] = 0;
|
||||
this.settingsService.setUser(user)
|
||||
this.router.navigateByUrl('/');
|
||||
this.settingsService.setUser(user);
|
||||
//this.router.navigateByUrl('/');
|
||||
} else {
|
||||
if (res.message) {
|
||||
this.msg.error(res.message);
|
||||
return
|
||||
return;
|
||||
}
|
||||
this.msg.error(this.i18n.fanyi('mxk.alert.operate.error'));
|
||||
}
|
||||
@ -210,7 +204,4 @@ export class PasswordComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ public class ChangePasswodController {
|
||||
return new Message<>(passwordPolicy);
|
||||
}
|
||||
|
||||
@PostMapping(value = { "/changePassword" })
|
||||
@PutMapping(value = { "/changePassword" })
|
||||
public Message<ChangePassword> changePasswod(
|
||||
@RequestBody ChangePassword changePassword,
|
||||
@CurrentUser UserInfo currentUser) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user