diff --git a/dmp-frontend/src/app/core/model/configuration-models/auth-providers.model.ts b/dmp-frontend/src/app/core/model/configuration-models/auth-providers.model.ts index 0a292db47..4af2f7439 100644 --- a/dmp-frontend/src/app/core/model/configuration-models/auth-providers.model.ts +++ b/dmp-frontend/src/app/core/model/configuration-models/auth-providers.model.ts @@ -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; } diff --git a/dmp-frontend/src/app/core/services/user/user.service.ts b/dmp-frontend/src/app/core/services/user/user.service.ts index 79e5b6049..c0d7e6cc0 100644 --- a/dmp-frontend/src/app/core/services/user/user.service.ts +++ b/dmp-frontend/src/app/core/services/user/user.service.ts @@ -107,6 +107,14 @@ export class UserService { catchError((error: any) => throwError(error))); } + confirmMergeAccount(token: Guid): Observable { + const url = `${this.apiBase}/mine/confirm-merge-account/token/${token}`; + + return this.http + .get(url).pipe( + catchError((error: any) => throwError(error))); + } + // // Autocomplete Commons // diff --git a/dmp-frontend/src/app/ui/auth/login/login.routing.ts b/dmp-frontend/src/app/ui/auth/login/login.routing.ts index c874ba0c7..403d00cc1 100644 --- a/dmp-frontend/src/app/ui/auth/login/login.routing.ts +++ b/dmp-frontend/src/app/ui/auth/login/login.routing.ts @@ -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 }, ]; diff --git a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.html b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.html index 8b1378917..d6f8d073f 100644 --- a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.html +++ b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.html @@ -1 +1,27 @@ - + diff --git a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.scss b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.scss index e69de29bb..4f3ea9057 100644 --- a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.scss +++ b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.scss @@ -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; +} diff --git a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts index 20dd25566..490e0a772 100644 --- a/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts +++ b/dmp-frontend/src/app/ui/auth/login/merge-email-confirmation/merge-email-confirmation.component.ts @@ -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']); } } } diff --git a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts index 64abf8f93..c19b75f37 100644 --- a/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts +++ b/dmp-frontend/src/app/ui/user-profile/user-profile.component.ts @@ -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' }); } }, diff --git a/dmp-frontend/src/assets/config/config.json b/dmp-frontend/src/assets/config/config.json index c972dd08e..f43a62736 100644 --- a/dmp-frontend/src/assets/config/config.json +++ b/dmp-frontend/src/assets/config/config.json @@ -55,12 +55,12 @@ }, "authProviders": [ { - "name": "Google", + "name": "google", "providerClass": "googleIcon", "cultures": ["en"] }, { - "name": "Facebook", + "name": "facebook", "providerClass": "facebookIcon", "cultures": ["en"] } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index b08ec5217..06ed50115 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -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" + } } } \ No newline at end of file