#IB8ZT6 认证平台无法修改密码

This commit is contained in:
shimingxy 2024-12-05 08:44:53 +08:00
parent a1a9fab6d6
commit 5bde3eafff
2 changed files with 55 additions and 64 deletions

View File

@ -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',
@ -42,7 +42,7 @@ export class PasswordComponent implements OnInit {
policy: any = {};
passwordVisible = false;
policyMessage: any[] = [];
dynamicallyCheckPasswordErrorMsg = "";
dynamicallyCheckPasswordErrorMsg = '';
constructor(
private router: Router,
private fb: FormBuilder,
@ -58,7 +58,7 @@ export class PasswordComponent implements OnInit {
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,7 +69,6 @@ export class PasswordComponent implements OnInit {
this.cdr.detectChanges();
}
loadPolicy(): void {
this.policyMessage = [];
this.passwordService.passwordpolicy().subscribe(res => {
@ -83,7 +82,7 @@ export class PasswordComponent implements OnInit {
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 = '';
}
@ -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 strArr = Array.from(value);
let abc: any = [];
strArr.forEach(function (value: any, index, array) {
let code = value.charCodeAt()
let code = value.charCodeAt();
if (code >= 'a'.charCodeAt(0) && code <= 'z'.charCodeAt(0)) {
abc.push(value)
abc.push(value);
}
})
});
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 strArr = Array.from(value);
let ABC: any = [];
strArr.forEach(function (value: any, index, array) {
let code = value.charCodeAt()
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')
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 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)
number.push(value);
}
})
});
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)
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 (AllNumIsSame.indexOf(value) != -1) {
//$.type 是jquery的函数用来判断对象类型
number.push(value);
}
})
});
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 {
});
}
}
}

View File

@ -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) {