Add user merge related services and updates on existing services on the frontend

This commit is contained in:
George Kalampokis 2020-10-26 10:36:20 +02:00
parent e1212383ff
commit 9674ec2b6b
5 changed files with 39 additions and 1 deletions

View File

@ -94,7 +94,7 @@ public class UserManager {
public List<UserCredential> getCredentials(UUID userId) { public List<UserCredential> getCredentials(UUID userId) {
List<UserCredential> results = new ArrayList<>(); List<UserCredential> results = new ArrayList<>();
eu.eudat.data.entities.UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId); eu.eudat.data.entities.UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
List<Credential> credentials = apiContext.getOperationsContext().getDatabaseRepository().getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userInfo").get("id"), userId)).toList(); List<Credential> credentials = apiContext.getOperationsContext().getDatabaseRepository().getCredentialDao().asQueryable().where((builder, root) -> builder.equal(root.get("userInfo"), user)).toList();
credentials.forEach(credential -> { credentials.forEach(credential -> {
UserCredential userCredential = new UserCredential(); UserCredential userCredential = new UserCredential();
userCredential.setEmail(credential.getEmail()); userCredential.setEmail(credential.getEmail());

View File

@ -0,0 +1,4 @@
export class UserMergeRequestModel {
userId: String;
email: String;
}

View File

@ -0,0 +1,6 @@
import { AuthProvider } from '@app/core/common/enum/auth-provider';
export class UserCredentialModel {
email: string;
provider: AuthProvider;
}

View File

@ -0,0 +1,23 @@
import { HttpHeaders } from '@angular/common/http';
import { Injectable } from "@angular/core";
import { BaseHttpService } from "../http/base-http.service";
import { ConfigurationService } from '../configuration/configuration.service';
import { UserMergeRequestModel } from '@app/core/model/merge/user-merge-request';
@Injectable()
export class MergeEmailConfirmationService {
private actioUrl: string;
private headers: HttpHeaders
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actioUrl = configurationService.server + 'emailMergeConfirmation/';
}
public emailConfirmation(token: string) {
return this.http.get<String>(this.actioUrl + token, { headers: this.headers });
}
public sendConfirmationEmail(mergeRequest: UserMergeRequestModel) {
return this.http.post<String>(this.actioUrl, mergeRequest, { headers: this.headers });
}
}

View File

@ -8,6 +8,7 @@ import { UserListingModel } from '../../model/user/user-listing';
import { UserCriteria } from '../../query/user/user-criteria'; import { UserCriteria } from '../../query/user/user-criteria';
import { BaseHttpService } from '../http/base-http.service'; import { BaseHttpService } from '../http/base-http.service';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { UserCredentialModel } from '@app/core/model/user/user-credential';
@Injectable() @Injectable()
export class UserService { export class UserService {
@ -28,6 +29,10 @@ export class UserService {
return this.http.get<UserListingModel>(this.actionUrl + id, { headers: this.headers }); return this.http.get<UserListingModel>(this.actionUrl + id, { headers: this.headers });
} }
getEmails(id: String): Observable<UserCredentialModel[]> {
return this.http.get<UserCredentialModel[]>(`${this.actionUrl}${id}/emails`, { headers: this.headers });
}
updateRoles(itemToUpdate: UserListingModel): Observable<UserListingModel> { updateRoles(itemToUpdate: UserListingModel): Observable<UserListingModel> {
return this.http.post<UserListingModel>(this.actionUrl + 'updateRoles', JSON.stringify(itemToUpdate), { headers: this.headers }); return this.http.post<UserListingModel>(this.actionUrl + 'updateRoles', JSON.stringify(itemToUpdate), { headers: this.headers });
} }