Merge pull request 'reset user password api' (#27) from mazdak/UX-1861 into dev-pending-01-01-2026

Reviewed-on: https://ct.mfsys.com.pk/aConnect/aConnect-UX/pulls/27
mazdak/UX-1887
Naeem Ullah 4 weeks ago
commit c6b660a80e

@ -7,7 +7,8 @@ export class User {
export interface SetupUser { export interface SetupUser {
userId: string; userId: string;
userFullname: string; userFullname: string;
defaultPassword: string; password: string;
porOrgacode: string | null;
email: string; email: string;
role: string; role: string;
} }

@ -122,7 +122,8 @@ constructor(private fb: FormBuilder, private httpURIService: HttpURIService, pri
oldPassword: form.get('oldPassword')?.value || null, oldPassword: form.get('oldPassword')?.value || null,
// confirmPassword: form.get('confirmPassword')?.value || null, // confirmPassword: form.get('confirmPassword')?.value || null,
newPassword: form.get('newPassword')?.value, newPassword: form.get('newPassword')?.value,
userId: this.storageService.getItem('USER_ID') userId: this.storageService.getItem('USER_ID'),
porOrgaCode: this.storageService.getItem('POR_ORGACODE')
}; };
} }
onSubmit(){ onSubmit(){

@ -5,6 +5,7 @@ import { CommonModule } from '@angular/common';
import { PasswordHideShowComponent } from '../../shared/components/password-hide-show/password-hide-show.component'; import { PasswordHideShowComponent } from '../../shared/components/password-hide-show/password-hide-show.component';
import { URIKey } from '../../utils/uri-enums'; import { URIKey } from '../../utils/uri-enums';
import { HttpURIService } from '../../app.http.uri.service'; import { HttpURIService } from '../../app.http.uri.service';
import { StorageService } from '../../shared/services/storage.service';
@Component({ @Component({
selector: 'app-reset-password', selector: 'app-reset-password',
@ -20,11 +21,13 @@ export class ResetPasswordComponent implements OnInit{
@ViewChild('psh1') passwordHideShow1?: PasswordHideShowComponent; @ViewChild('psh1') passwordHideShow1?: PasswordHideShowComponent;
@ViewChild('psh2') passwordHideShow2?: PasswordHideShowComponent; @ViewChild('psh2') passwordHideShow2?: PasswordHideShowComponent;
constructor(private fb: FormBuilder, private httpURIService: HttpURIService){} constructor(private fb: FormBuilder, private httpURIService: HttpURIService, private storageService: StorageService){}
ngOnInit(): void { ngOnInit(): void {
const userIdValue = this.storageService.getItem('USER_ID')
this.resetPasswordForm = this.fb.group({ this.resetPasswordForm = this.fb.group({
userId: ['', Validators.required],
userId: [userIdValue || '', Validators.required],
newPassword: ['', [Validators.required, Validators.minLength(6)]], newPassword: ['', [Validators.required, Validators.minLength(6)]],
confirmPassword: ['', [Validators.required, Validators.minLength(6)]] confirmPassword: ['', [Validators.required, Validators.minLength(6)]]
}, },
@ -76,7 +79,8 @@ export class ResetPasswordComponent implements OnInit{
const payload = { const payload = {
userId: this.resetPasswordForm.value.userId, userId: this.resetPasswordForm.value.userId,
newPassword: this.resetPasswordForm.value.newPassword newPassword: this.resetPasswordForm.value.newPassword,
porOrgaCode: this.storageService.getItem('POR_ORGACODE')
}; };
this.httpURIService.requestPOST(URIKey.RESET_PASSWORD_URI, payload) this.httpURIService.requestPOST(URIKey.RESET_PASSWORD_URI, payload)
.subscribe(); .subscribe();

@ -8,6 +8,7 @@ import { SetupUser } from '../../models/user';
import { UserSetupService } from '../../services/user-setup.service'; import { UserSetupService } from '../../services/user-setup.service';
import { UserFilterPipe } from '../../shared/pipes/userFilterPipe'; import { UserFilterPipe } from '../../shared/pipes/userFilterPipe';
import { FormBuilder, Validators, FormGroup } from '@angular/forms'; import { FormBuilder, Validators, FormGroup } from '@angular/forms';
import { StorageService } from '../../shared/services/storage.service';
@Component({ @Component({
@ -34,7 +35,7 @@ export class SetupUserComponent implements OnInit {
mode: 'edit' | 'view' = 'view'; mode: 'edit' | 'view' = 'view';
constructor(private userService: UserSetupService, private fb: FormBuilder){} constructor(private userService: UserSetupService, private fb: FormBuilder, private storageService: StorageService){}
get users$(){ get users$(){
return this.userService.users$; return this.userService.users$;
@ -70,8 +71,10 @@ export class SetupUserComponent implements OnInit {
userFullname: this.userForm.value.userFullname, userFullname: this.userForm.value.userFullname,
email: `${this.userForm.value.userId}@dummy.com`, email: `${this.userForm.value.userId}@dummy.com`,
role: 'ADMIN', role: 'ADMIN',
defaultPassword: this.userForm.value.defaultPassword porOrgacode: this.storageService.getItem('POR_ORGACODE'),
password: this.userForm.value.defaultPassword
} }
this.userService.addUser(newUser).subscribe({ this.userService.addUser(newUser).subscribe({
next: () => { next: () => {
this.userService.loadUsers(); this.userService.loadUsers();

@ -49,7 +49,7 @@
}, },
{ {
"Id" : "ENTITY_RESET_PASSWORD_URI", "Id" : "ENTITY_RESET_PASSWORD_URI",
"URI": "/user/resetPassword", "URI": "/authentication/reset-password",
"UUID": "RESET_PASSWORD_URI" "UUID": "RESET_PASSWORD_URI"
}, },
{ {

Loading…
Cancel
Save