user-profile > unlink account

This commit is contained in:
Sofia Papacharalampous 2024-03-26 15:57:59 +02:00
parent dff8785e7b
commit 8be851763b
4 changed files with 22 additions and 3 deletions

View File

@ -50,7 +50,7 @@ public class RemoveCredentialRequestPersist {
protected List<Specification> specifications(RemoveCredentialRequestPersist item) { protected List<Specification> specifications(RemoveCredentialRequestPersist item) {
return Arrays.asList( return Arrays.asList(
this.spec() this.spec()
.must(() -> !this.isValidGuid(item.getCredentialId())) .must(() -> this.isValidGuid(item.getCredentialId()))
.failOn(RemoveCredentialRequestPersist._credentialId).failWith(messageSource.getMessage("Validation_Required", new Object[]{RemoveCredentialRequestPersist._credentialId}, LocaleContextHolder.getLocale())) .failOn(RemoveCredentialRequestPersist._credentialId).failWith(messageSource.getMessage("Validation_Required", new Object[]{RemoveCredentialRequestPersist._credentialId}, LocaleContextHolder.getLocale()))
); );
} }

View File

@ -79,3 +79,7 @@ export interface DmpAssociatedUser {
export interface UserMergeRequestPersist { export interface UserMergeRequestPersist {
email: string; email: string;
} }
export interface RemoveCredentialRequestPersist {
credentialId: Guid;
}

View File

@ -1,7 +1,7 @@
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum'; import { IsActive } from '@app/core/common/enum/is-active.enum';
import { DmpAssociatedUser, User, UserMergeRequestPersist, UserPersist, UserRolePatchPersist } from '@app/core/model/user/user'; import { DmpAssociatedUser, RemoveCredentialRequestPersist, User, UserMergeRequestPersist, UserPersist, UserRolePatchPersist } from '@app/core/model/user/user';
import { UserLookup } from '@app/core/query/user.lookup'; import { UserLookup } from '@app/core/query/user.lookup';
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration'; import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
@ -106,6 +106,16 @@ export class UserService {
.post<boolean>(url, item).pipe( .post<boolean>(url, item).pipe(
catchError((error: any) => throwError(error))); catchError((error: any) => throwError(error)));
} }
removeCredentialAccount(item: RemoveCredentialRequestPersist): Observable<boolean> {
const url = `${this.apiBase}/mine/remove-credential-request`;
console.log(item);
console.log(url);
return this.http
.post<boolean>(url, item).pipe(
catchError((error: any) => throwError(error)));
}
confirmMergeAccount(token: Guid): Observable<boolean> { confirmMergeAccount(token: Guid): Observable<boolean> {
const url = `${this.apiBase}/mine/confirm-merge-account/token/${token}`; const url = `${this.apiBase}/mine/confirm-merge-account/token/${token}`;

View File

@ -296,8 +296,13 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
.afterClosed() .afterClosed()
.subscribe(confirm => { .subscribe(confirm => {
if (confirm) { if (confirm) {
this.userService.removeCredentialAccount({ credentialId: userCredential.user.id }).subscribe(result => {
//TODO
},
error => console.error(error));
//TODO: refactor //TODO: refactor
console.log('removed!');
// const unlinkAccountModel: UnlinkAccountRequestModel = { // const unlinkAccountModel: UnlinkAccountRequestModel = {
// userId: this.currentUserId, // userId: this.currentUserId,
// email: userCredential.email, // email: userCredential.email,