1
0
mirror of https://github.com/google/nomulus synced 2026-01-09 23:47:49 +00:00

Add console epp password integration (#2426)

This commit is contained in:
Pavlo Tkach
2024-05-06 14:32:54 -04:00
committed by GitHub
parent 2c7bf2cfdb
commit 54c896cbb9
5 changed files with 57 additions and 16 deletions

View File

@@ -7,7 +7,7 @@
*matTreeNodeDef="let node"
matTreeNodeToggle
(click)="onClick(node)"
[class.active]="router.url.endsWith(node.path)"
[class.active]="router.url.includes(node.path)"
>
<mat-icon class="console-app__nav-icon" *ngIf="node.iconName">
{{ node.iconName }}

View File

@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { HttpErrorResponse } from '@angular/common/http';
import { Component } from '@angular/core';
import {
AbstractControl,
@@ -68,9 +69,12 @@ export default class EppPasswordEditComponent {
) {
this.passwordUpdateForm?.get('newPasswordRepeat')?.setErrors(null);
} else {
this.passwordUpdateForm
?.get('newPasswordRepeat')
?.setErrors({ passwordsDontMatch: control.value });
// latest angular just won't detect the error without setTimeout
setTimeout(() => {
this.passwordUpdateForm
?.get('newPasswordRepeat')
?.setErrors({ passwordsDontMatch: control.value });
});
}
return null;
};
@@ -92,15 +96,24 @@ export default class EppPasswordEditComponent {
});
save() {
debugger;
// this.securityService.saveEppPassword().subscribe({
// complete: () => {
// this.goBack();
// },
// error: (err: HttpErrorResponse) => {
// this._snackBar.open(err.error);
// },
// });
const { oldPassword, newPassword, newPasswordRepeat } =
this.passwordUpdateForm.value;
if (!oldPassword || !newPassword || !newPasswordRepeat) return;
this.securityService
.saveEppPassword({
registrarId: this.registrarService.registrarId(),
oldPassword,
newPassword,
newPasswordRepeat,
})
.subscribe({
complete: () => {
this.goBack();
},
error: (err: HttpErrorResponse) => {
this._snackBar.open(err.error);
},
});
}
goBack() {

View File

@@ -22,6 +22,13 @@ import {
} from 'src/app/registrar/registrar.service';
import { BackendService } from 'src/app/shared/services/backend.service';
export interface EppPasswordBackendModel {
registrarId: string;
oldPassword: string;
newPassword: string;
newPasswordRepeat: string;
}
export function apiToUiConverter(
securitySettings: SecuritySettingsBackendModel = {}
): SecuritySettings {
@@ -68,5 +75,11 @@ export class SecurityService {
);
}
saveEppPassword() {}
saveEppPassword(data: EppPasswordBackendModel) {
return this.backend.postEppPasswordUpdate(data).pipe(
switchMap(() => {
return this.registrarService.loadRegistrars();
})
);
}
}

View File

@@ -17,12 +17,14 @@ import { Injectable } from '@angular/core';
import { Observable, catchError, of, throwError } from 'rxjs';
import { DomainListResult } from 'src/app/domains/domainList.service';
import { environment } from 'src/environments/environment';
import {
Registrar,
SecuritySettingsBackendModel,
WhoisRegistrarFields,
} from '../../registrar/registrar.service';
import { Contact } from '../../settings/contact/contact.service';
import { EppPasswordBackendModel } from '../../settings/security/security.service';
import { UserData } from './userData.service';
@Injectable()
@@ -35,7 +37,11 @@ export class BackendService {
): Observable<Type> {
// This is a temporary redirect to the old console untill the new console
// is fully released and enabled
if (error.url && window.location.href.indexOf(error.url) < 0) {
if (
environment.production &&
error.url &&
window.location.href.indexOf(error.url) < 0
) {
window.location.href = error.url;
}
if (error.error instanceof Error) {
@@ -139,6 +145,15 @@ export class BackendService {
);
}
postEppPasswordUpdate(
data: EppPasswordBackendModel
): Observable<EppPasswordBackendModel> {
return this.http.post<EppPasswordBackendModel>(
`/console-api/eppPassword`,
data
);
}
getUserData(): Observable<UserData> {
return this.http
.get<UserData>('/console-api/userdata')

View File

@@ -30,7 +30,7 @@ export interface GlobalLoader {
providedIn: 'root',
})
export class GlobalLoaderService {
private static readonly TIMEOUT_MS = 3000;
private static readonly TIMEOUT_MS = 10000;
private loaders = new Map<GlobalLoader, Subscription>();
public isLoading: boolean = false;