#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 { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, Inject } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { I18NService } from '@core'; import { I18NService } from '@core';
import { SettingsService, User, ALAIN_I18N_TOKEN } from '@delon/theme'; import { SettingsService, User, ALAIN_I18N_TOKEN } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message'; import { NzMessageService } from 'ng-zorro-antd/message';
import { Router, ActivatedRoute } from '@angular/router';
import { ChangePassword } from '../../../entity/ChangePassword'; import { ChangePassword } from '../../../entity/ChangePassword';
import { PasswordService } from '../../../service/password.service'; import { PasswordService } from '../../../service/password.service';
@Component({ @Component({
selector: 'app-password', selector: 'app-password',
templateUrl: './password.component.html', templateUrl: './password.component.html',
@ -39,10 +39,10 @@ export class PasswordComponent implements OnInit {
}; };
validateForm!: FormGroup; validateForm!: FormGroup;
oldPasswordVisible = false; oldPasswordVisible = false;
policy:any = {}; policy: any = {};
passwordVisible = false; passwordVisible = false;
policyMessage:any[] =[]; policyMessage: any[] = [];
dynamicallyCheckPasswordErrorMsg = ""; dynamicallyCheckPasswordErrorMsg = '';
constructor( constructor(
private router: Router, private router: Router,
private fb: FormBuilder, private fb: FormBuilder,
@ -51,14 +51,14 @@ export class PasswordComponent implements OnInit {
private msg: NzMessageService, private msg: NzMessageService,
@Inject(ALAIN_I18N_TOKEN) private i18n: I18NService, @Inject(ALAIN_I18N_TOKEN) private i18n: I18NService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef
) { } ) {}
ngOnInit(): void { ngOnInit(): void {
this.loadPolicy(); this.loadPolicy();
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
oldPassword: [null, [Validators.required]], oldPassword: [null, [Validators.required]],
confirmPassword: [null, [Validators.required]], confirmPassword: [null, [Validators.required]],
password: [null, [Validators.required]], password: [null, [Validators.required]]
}); });
let user: any = this.settingsService.user; let user: any = this.settingsService.user;
@ -69,27 +69,26 @@ export class PasswordComponent implements OnInit {
this.cdr.detectChanges(); this.cdr.detectChanges();
} }
loadPolicy(): void {
loadPolicy():void { this.policyMessage = [];
this.policyMessage=[];
this.passwordService.passwordpolicy().subscribe(res => { this.passwordService.passwordpolicy().subscribe(res => {
if(res.code == 0) { if (res.code == 0) {
let data = res.data; let data = res.data;
this.policy = 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) { if (value != this.form.model.password) {
this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.twice') this.dynamicallyCheckPasswordErrorMsg = this.i18n.fanyi('validation.password.twice');
} else { } else {
this.dynamicallyCheckPasswordErrorMsg = ''; this.dynamicallyCheckPasswordErrorMsg = '';
} }
} }
dynamicallyCheckPassword(value:any):void { dynamicallyCheckPassword(value: any): void {
if (value == '') { if (value == '') {
this.dynamicallyCheckPasswordErrorMsg = ''; this.dynamicallyCheckPasswordErrorMsg = '';
return; return;
@ -99,78 +98,76 @@ export class PasswordComponent implements OnInit {
let inputLength = value.length; let inputLength = value.length;
if (inputLength < data.minLength || inputLength > data.maxLength) { if (inputLength < data.minLength || inputLength > data.maxLength) {
//this.dynamicallyCheckPasswordErrorMsg = "限定新密码长度为"+data.minLength+"-"+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; return;
} }
} }
if (data.lowerCase > 0) { if (data.lowerCase > 0) {
let strArr = Array.from(value) let strArr = Array.from(value);
let abc:any = []; let abc: any = [];
strArr.forEach(function (value:any, index, array) { strArr.forEach(function (value: any, index, array) {
let code = value.charCodeAt() let code = value.charCodeAt();
if (code >= 'a'.charCodeAt(0) && code <= 'z'.charCodeAt(0)) { 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 = "限定新密码至少需要包含"+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; return;
} }
} }
if (data.upperCase > 0) {
if(data.upperCase > 0) { let strArr = Array.from(value);
let strArr = Array.from(value) let ABC: any = [];
let ABC:any = []; strArr.forEach(function (value: any, index, array) {
strArr.forEach(function (value:any, index, array) { let code = value.charCodeAt();
let code = value.charCodeAt()
if (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0)) { if (code >= 'A'.charCodeAt(0) && code <= 'Z'.charCodeAt(0)) {
ABC.push(value) ABC.push(value);
} }
}) });
if(ABC.length < data.upperCase) { 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】大写字母" //this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.lowerCase+"位【A-Z】大写字母"
return; return;
} }
} }
if (data.digits > 0) { if (data.digits > 0) {
let strArr = Array.from(value) let strArr = Array.from(value);
let number:any = []; let number: any = [];
strArr.forEach(function (value:any, index, array) { strArr.forEach(function (value: any, index, array) {
var regPos = /^[0-9]+.?[0-9]*/; //判断是否是数字。 var regPos = /^[0-9]+.?[0-9]*/; //判断是否是数字。
if(regPos.test(value) ){ if (regPos.test(value)) {
number.push(value) number.push(value);
} }
}) });
if(number.length < data.digits) { if (number.length < data.digits) {
//this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+data.digits+"位【0-9】阿拉伯数字"; //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; return;
} }
} }
if (data.specialChar > 0) {
if(data.specialChar > 0) { var AllNumIsSame = new Array('', '”', '!', '@', '#', '$', '%', '^', '&', '*', '.');
var AllNumIsSame = new Array("","”","!","@","#","$","%","^","&","*","."); let strArr = Array.from(value);
let strArr = Array.from(value) let number: any = [];
let number:any = []; strArr.forEach(function (value: any, index, array) {
strArr.forEach(function (value:any, index, array) { if (AllNumIsSame.indexOf(value) != -1) {
if(AllNumIsSame.indexOf(value) != -1){//$.type 是jquery的函数用来判断对象类型 //$.type 是jquery的函数用来判断对象类型
number.push(value) number.push(value);
} }
}) });
if(number.length < data.specialChar) { if (number.length < data.specialChar) {
//this.dynamicallyCheckPasswordErrorMsg = "限定新密码至少需要包含"+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; return;
} }
} }
this.dynamicallyCheckPasswordErrorMsg = ''; this.dynamicallyCheckPasswordErrorMsg = '';
} }
onSubmit(): void { onSubmit(): void {
@ -182,18 +179,15 @@ export class PasswordComponent implements OnInit {
if (res.code == 0) { if (res.code == 0) {
this.form.model.init(res.data); this.form.model.init(res.data);
this.msg.success(this.i18n.fanyi('mxk.alert.operate.success')); 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; let user = this.settingsService.user;
user['passwordSetType'] = 0; user['passwordSetType'] = 0;
this.settingsService.setUser(user) this.settingsService.setUser(user);
this.router.navigateByUrl('/'); //this.router.navigateByUrl('/');
} else { } else {
if (res.message) { if (res.message) {
this.msg.error(res.message); this.msg.error(res.message);
return return;
} }
this.msg.error(this.i18n.fanyi('mxk.alert.operate.error')); 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); return new Message<>(passwordPolicy);
} }
@PostMapping(value = { "/changePassword" }) @PutMapping(value = { "/changePassword" })
public Message<ChangePassword> changePasswod( public Message<ChangePassword> changePasswod(
@RequestBody ChangePassword changePassword, @RequestBody ChangePassword changePassword,
@CurrentUser UserInfo currentUser) { @CurrentUser UserInfo currentUser) {