diff --git a/login/user.component.html b/login/user.component.html
index 5f6aa719..5f54a8c1 100644
--- a/login/user.component.html
+++ b/login/user.component.html
@@ -53,16 +53,13 @@
Please sign in to continue.
-
+
You are not authorized to use the requested page.
-
- You are not authorized to use the requested page.
-
There is no research community selected.
diff --git a/login/verification.guard.ts b/login/verification.guard.ts
new file mode 100644
index 00000000..8fc3399f
--- /dev/null
+++ b/login/verification.guard.ts
@@ -0,0 +1,44 @@
+import {Injectable} from '@angular/core';
+import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
+import {Observable} from 'rxjs/Observable';
+import {Session} from './utils/helper.class';
+import {LoginErrorCodes} from './utils/guardHelper.class';
+import {filter, map, mergeMap} from "rxjs/operators";
+import {UserManagementService} from "../services/user-management.service";
+import {UserRegistryService} from "../services/user-registry.service";
+import {of} from "rxjs";
+
+@Injectable()
+export class VerificationGuard implements CanActivate {
+
+ constructor(private router: Router,
+ private userRegistryService: UserRegistryService,
+ private userManagementService: UserManagementService) {
+ }
+
+ check(path: string): Observable
| boolean {
+ if (Session.isLoggedIn()) {
+ const obs = this.userManagementService.getUserInfo(false).pipe(map(user => {
+ if(user) {
+ of(true);
+ } else {
+ return of(false);
+ }
+ }), mergeMap(authorized => {
+ return authorized;
+ }));
+ obs.pipe(filter(isLoggedIn => !isLoggedIn)).subscribe(() => {
+ this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, path}});
+ });
+ return obs;
+ } else {
+ this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, path}});
+ return false;
+ }
+ }
+
+ canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | boolean {
+ console.log(route);
+ return this.check(state.url);
+ }
+}
diff --git a/services/user-registry.service.ts b/services/user-registry.service.ts
index e6468428..9785e02a 100644
--- a/services/user-registry.service.ts
+++ b/services/user-registry.service.ts
@@ -39,6 +39,11 @@ export class UserRegistryService {
return this.http.get(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/subscribers/email').pipe(map(response => response.response));
}
+ public getInvitation(id: string): Observable {
+ return this.http.get(properties.registryUrl + "verification/" + encodeURIComponent(id))
+ .pipe(map(response => response.response), CustomOptions.registryOptions());
+ }
+
public getManagersEmail(type: string, id: string): Observable {
return this.http.get(properties.registryUrl + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/managers/email').pipe(map(response => response.response));
}
diff --git a/utils/piwik/previousRouteRecorder.guard.ts b/utils/piwik/previousRouteRecorder.guard.ts
index d10b7407..4f9e762e 100644
--- a/utils/piwik/previousRouteRecorder.guard.ts
+++ b/utils/piwik/previousRouteRecorder.guard.ts
@@ -3,7 +3,9 @@ import { Injectable } from '@angular/core';
import { CanDeactivate, Router} from '@angular/router';
import {Observable} from 'rxjs';
-@Injectable() // do not forget to register this class as a provider
+@Injectable({
+ providedIn: 'root'
+}) // do not forget to register this class as a provider
export class PreviousRouteRecorder implements CanDeactivate {
constructor(private router: Router) {
}
diff --git a/verification/verification.component.ts b/verification/verification.component.ts
new file mode 100644
index 00000000..5f6e5a7f
--- /dev/null
+++ b/verification/verification.component.ts
@@ -0,0 +1,9 @@
+import {Component} from "@angular/core";
+
+@Component({
+ selector: 'verification',
+ template: ``
+})
+export class VerificationComponent {
+
+}
diff --git a/verification/verification.module.ts b/verification/verification.module.ts
new file mode 100644
index 00000000..cb9fb5a2
--- /dev/null
+++ b/verification/verification.module.ts
@@ -0,0 +1,10 @@
+import {NgModule} from "@angular/core";
+import {CommonModule} from "@angular/common";
+import {VerificationComponent} from "./verification.component";
+
+@NgModule({
+ imports: [CommonModule],
+ declarations: [VerificationComponent],
+ exports: [VerificationComponent]
+})
+export class VerificationModule {}