1. added merge-account-confirm page 2. fixed config for google-auth-provider

This commit is contained in:
Sofia Papacharalampous 2024-03-26 13:23:56 +02:00
parent e4516ef0ed
commit 5387a2c3df
9 changed files with 107 additions and 18 deletions

View File

@ -28,7 +28,7 @@ export class AuthProviders {
public findOrGetDefault(providerName: string, culture: string): AuthProvider {
const authProvider = this.find(providerName, culture);
if (authProvider === null) return this.defaultAuthProvider;
if (authProvider === undefined) return this.defaultAuthProvider;
return authProvider;
}

View File

@ -107,6 +107,14 @@ export class UserService {
catchError((error: any) => throwError(error)));
}
confirmMergeAccount(token: Guid): Observable<boolean> {
const url = `${this.apiBase}/mine/confirm-merge-account/token/${token}`;
return this.http
.get<boolean>(url).pipe(
catchError((error: any) => throwError(error)));
}
//
// Autocomplete Commons
//

View File

@ -3,10 +3,15 @@ import { RouterModule, Routes } from '@angular/router';
import { LoginComponent } from './login.component';
import { MergeEmailConfirmation } from './merge-email-confirmation/merge-email-confirmation.component';
import { UnlinkEmailConfirmation } from './unlink-email-confirmation/unlink-email-confirmation.component';
import { AuthGuard } from '@app/core/auth-guard.service';
const routes: Routes = [
{ path: '', component: LoginComponent },
{ path: 'merge/confirmation/:token', component: MergeEmailConfirmation },
{
path: 'merge/confirmation/:token',
component: MergeEmailConfirmation,
canActivate: [AuthGuard]
},
{ path: 'unlink/confirmation/:token', component: UnlinkEmailConfirmation },
];

View File

@ -1 +1,27 @@
<div class="merge-account">
<div class="container-fluid">
<div class="row">
<div class="col merge-account-title">{{'MERGE-ACCOUNT.TITLE' | translate}}</div>
</div>
<div *ngIf="showForm" class="row merge-account-content">
<div class="col">
<div class="row justify-content-center">
<div class="col-auto">
<span>
{{ 'MERGE-ACCOUNT.MESSAGES.CONFIRMATION' | translate }}
</span>
<!-- <span>Duo ea clita doming eu stet. Nonummy voluptua accusam sit eos aliquyam sit kasd lorem ut feugait no et soluta invidunt ea sanctus. Ut erat molestie sit sit diam dolores lorem nonumy quis consetetur. Elitr sed euismod illum sit consetetur esse at eum elitr sit dolores ut facer. Autem in aliquyam magna eos dolore eos amet ut magna sadipscing sea eum. Justo elitr aliquip praesent est exerci dolore commodo accusam dolor hendrerit rebum feugiat aliquyam sadipscing sed. Dolores dolore autem in et dolor at adipiscing ullamcorper invidunt vel. Et takimata ea amet et at sit kasd erat magna sed.</span> -->
</div>
</div>
<div class="row justify-content-center">
<div class="col-auto mt-4">
<!-- -->
<button type="button" class="normal-btn" (click)="onConfirm()">{{ 'MERGE-ACCOUNT.ACTIONS.CONFIRM' | translate }}</button>
</div>
</div>
</div>
</div>
<ng-template #loading>
</ng-template>
</div>
</div>

View File

@ -0,0 +1,19 @@
.merge-account {
height: fit-content;
//margin-top: 80px;
min-height: 100vh;
background-color: #ffffff;
}
.merge-account-title {
font-size: 1.25rem;
color: #212121;
padding-top: 4.1875rem;
padding-left: 3.75rem;
padding-bottom: 4.0625rem;
}
.merge-account-content {
margin-left: 9rem;
margin-right: 11rem;
}

View File

@ -1,30 +1,41 @@
import { Component, OnInit } from "@angular/core";
import { UntypedFormControl } from '@angular/forms';
import { MatDialog } from "@angular/material/dialog";
import { ActivatedRoute, Router } from "@angular/router";
import { AuthService } from "@app/core/services/auth/auth.service";
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { UserService } from "@app/core/services/user/user.service";
import { PopupNotificationDialogComponent } from "@app/library/notification/popup/popup-notification.component";
import { BaseComponent } from '@common/base/base.component';
import { Guid } from "@common/types/guid";
import { TranslateService } from '@ngx-translate/core';
import { takeUntil } from "rxjs/operators";
@Component({
selector: 'app-email-confirmation-component',
templateUrl: './merge-email-confirmation.component.html'
templateUrl: './merge-email-confirmation.component.html',
styleUrls: ['./merge-email-confirmation.component.scss']
})
export class MergeEmailConfirmation extends BaseComponent implements OnInit {
private token: Guid;
public emailFormControl = new UntypedFormControl('');
public showForm: boolean = false;
public mailSent: boolean = false;
get showForm(): boolean {
return this.token != null;
}
constructor(
//TODO: refactor
// private emailConfirmationService: MergeEmailConfirmationService,
private authService: AuthService,
// private authService: AuthService,
private userService: UserService,
private route: ActivatedRoute,
private router: Router,
private language: TranslateService,
private uiNotificationService: UiNotificationService
private uiNotificationService: UiNotificationService,
) { super(); }
ngOnInit() {
@ -33,7 +44,8 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit {
.subscribe(params => {
const token = params['token']
if (token != null) {
this.showForm = false;
this.token = token;
// this.showForm = false;
//TODO: refactor
// this.emailConfirmationService.emailConfirmation(token)
// .pipe(takeUntil(this._destroyed))
@ -48,11 +60,25 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit {
// error => this.onCallbackError(error)
// )
} else {
this.showForm = true;
// this.showForm = true;
}
});
}
onConfirm(): void {
console.log('onConfirm');
if (this.showForm === false) return;
console.log('active');
this.userService.confirmMergeAccount(this.token)
.subscribe(result => {
if (result) {
this.onCallbackEmailConfirmationSuccess();
}
},
error => this.onCallbackError(error));
}
onCallbackEmailConfirmationSuccess() {
this.router.navigate(['home']);
}
@ -63,7 +89,6 @@ export class MergeEmailConfirmation extends BaseComponent implements OnInit {
this.router.navigate(['home']);
} else {
this.uiNotificationService.snackBarNotification(this.language.instant('EMAIL-CONFIRMATION.EXPIRED-EMAIL'), SnackBarNotificationLevel.Error);
this.router.navigate(['login']);
}
}
}

View File

@ -99,10 +99,6 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
return providerNames;
}
public getProviderIcon(providerName:string, culture:string): string {
return this.configurationService.authProviders.find(providerName, culture).providerClass;
}
ngOnInit() {
this.matomoService.trackPageView('User Profile');
this.route.params
@ -345,7 +341,7 @@ export class UserProfileComponent extends BaseComponent implements OnInit, OnDes
data: {
title: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.TITLE'),
message: this.language.instant('USER-PROFILE.MERGING-EMAILS-DIALOG.MESSAGE')
}//, maxWidth: '30em'
}, maxWidth: '30em'
});
}
},

View File

@ -55,12 +55,12 @@
},
"authProviders": [
{
"name": "Google",
"name": "google",
"providerClass": "googleIcon",
"cultures": ["en"]
},
{
"name": "Facebook",
"name": "facebook",
"providerClass": "facebookIcon",
"cultures": ["en"]
}

View File

@ -1881,5 +1881,15 @@
"ACTIONS": {
"LEARN-MORE": "Learn more"
}
},
"MERGE-ACCOUNT": {
"TITLE": "Merge Your Account",
"MESSAGES": {
"CONFIRMATION": "Are you sure that you want to merge this account?"
},
"ACTIONS": {
"CONFIRM": "Confirm",
"CANCEL": "Cancel"
}
}
}