Check is LoggedIn from Session
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57064 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
69c86456b8
commit
95ee0d8984
|
@ -1,11 +1,10 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {ContextsService} from './service/contexts.service';
|
||||
import {ClaimEntity} from './claimHelper.class';
|
||||
import {ClaimContext, ClaimEntity} from './claimHelper.class';
|
||||
import {Session} from '../../login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {UserManagementService} from "../../services/user-management.service";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
|
@ -45,9 +44,7 @@ export class ClaimContextSearchFormComponent {
|
|||
this.getCommunities();
|
||||
}
|
||||
|
||||
constructor(private _contextService: ContextsService,
|
||||
private router: Router,
|
||||
private userManagementService: UserManagementService) {
|
||||
constructor(private _contextService: ContextsService, private router: Router) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -112,8 +109,7 @@ export class ClaimContextSearchFormComponent {
|
|||
}
|
||||
|
||||
getCommunities() {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this.saveStateAndRedirectLogin();
|
||||
|
||||
} else {
|
||||
|
@ -149,17 +145,16 @@ export class ClaimContextSearchFormComponent {
|
|||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getCategories() {
|
||||
this.loading = true;
|
||||
// this.categories=[];
|
||||
if (this.selectedCommunityId != '0') {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this.saveStateAndRedirectLogin();
|
||||
|
||||
|
||||
} else {
|
||||
if (this.categories[this.selectedCommunityId]) {
|
||||
this.loading = false;
|
||||
|
@ -183,10 +178,8 @@ export class ClaimContextSearchFormComponent {
|
|||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
getConcepts() {
|
||||
this.loading = true;
|
||||
|
@ -225,7 +218,6 @@ export class ClaimContextSearchFormComponent {
|
|||
this.loading = false;
|
||||
}
|
||||
}*/
|
||||
|
||||
/*
|
||||
getSubConcepts(conceptId) {
|
||||
this.loading = true;
|
||||
|
@ -269,10 +261,8 @@ export class ClaimContextSearchFormComponent {
|
|||
}
|
||||
|
||||
browseConcepts(categoryId) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
if (!Session.isLoggedIn()) {
|
||||
this.saveStateAndRedirectLogin();
|
||||
|
||||
} else {
|
||||
if (this.conceptsClass[categoryId] != null) {
|
||||
this.conceptsClassDisplay[categoryId] = !this.conceptsClassDisplay[categoryId];
|
||||
|
@ -302,7 +292,7 @@ export class ClaimContextSearchFormComponent {
|
|||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
browseSubConcepts(categoryId, conceptId) {
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
import {Component, QueryList, ViewChild, ViewChildren, ViewEncapsulation} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Meta, Title} from '@angular/platform-browser';
|
||||
import {Component, ViewChild, ViewChildren, QueryList, Input, ViewEncapsulation} from '@angular/core';
|
||||
import {Location} from '@angular/common';
|
||||
import {ActivatedRoute, Params, Router} from '@angular/router';
|
||||
import {Title, Meta} from '@angular/platform-browser';
|
||||
|
||||
import {DataTableDirective} from 'angular-datatables';
|
||||
import {Subject} from 'rxjs';
|
||||
import {Observable, Subject } from 'rxjs';
|
||||
|
||||
import{EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
|
||||
import {ClaimsDatatablePipe} from '../../utils/pipes/claimsDatatable.pipe';
|
||||
|
||||
import {RouterHelper} from '../../utils/routerHelper.class';
|
||||
|
||||
import {ModalSelect} from '../../utils/modal/selectModal.component';
|
||||
|
@ -18,7 +21,6 @@ import {ClaimsByTokenService} from './claimsByToken.service';
|
|||
|
||||
import {Session} from '../../login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
||||
import {UserManagementService} from "../../services/user-management.service";
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -87,14 +89,12 @@ export class ClaimsByTokenComponent {
|
|||
constructor (private route: ActivatedRoute,
|
||||
private _router: Router,
|
||||
private claimsByTokenService: ClaimsByTokenService,
|
||||
private _meta: Meta, private _title: Title,
|
||||
private userManagementService: UserManagementService) {
|
||||
private _meta: Meta, private _title: Title) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.pending_status = this.errorCodes.LOADING;
|
||||
this.curated_status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
|
@ -146,24 +146,17 @@ export class ClaimsByTokenComponent {
|
|||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (isLoggedIn) {
|
||||
$.fn['dataTable'].ext.search.push((settings, data, dataIndex) => {
|
||||
if(settings.sTableId == 'table1') {
|
||||
return !!this.filterData(data, this.keyword1);
|
||||
|
||||
if (this.filterData(data, this.keyword1)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if(settings.sTableId == 'table2') {
|
||||
return !!this.filterData(data, this.keyword2);
|
||||
|
||||
if (this.filterData(data, this.keyword2)) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -208,8 +201,12 @@ export class ClaimsByTokenComponent {
|
|||
});
|
||||
}
|
||||
|
||||
filterData(row: any, query: string): boolean {
|
||||
filterData(row: any, query: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
let returnValue: boolean = false;
|
||||
|
||||
if(query) {
|
||||
for(var i=0; i <3; i++){
|
||||
var r= this.filterQuery(row[i], query);
|
||||
|
@ -223,8 +220,10 @@ export class ClaimsByTokenComponent {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
filterQuery(data, query){
|
||||
if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){
|
||||
|
@ -235,14 +234,8 @@ export class ClaimsByTokenComponent {
|
|||
}
|
||||
|
||||
refreshTable(page:number, whichTable: string) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if(whichTable == "pending") {
|
||||
var table = $('#table1').DataTable();
|
||||
|
@ -262,21 +255,14 @@ export class ClaimsByTokenComponent {
|
|||
this.totalCuratedResults.count = info.recordsDisplay;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//table.mfActivePage=$event.value;
|
||||
//table.setPage(table.mfActivePage, this.rowsOnPage);
|
||||
}
|
||||
|
||||
validateJWTandToken() {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if(this.openaireId) {
|
||||
this.pending_status = this.errorCodes.LOADING;
|
||||
|
@ -371,18 +357,11 @@ export class ClaimsByTokenComponent {
|
|||
this.accessStatus = "invalid";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
selectApprove(id:string, event, mode: string) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
var value = event.currentTarget.checked;
|
||||
if(value){
|
||||
|
@ -403,18 +382,11 @@ export class ClaimsByTokenComponent {
|
|||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
selectDisapprove(id:string, event, mode: string) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
var value = event.currentTarget.checked;
|
||||
if(value){
|
||||
|
@ -435,13 +407,11 @@ export class ClaimsByTokenComponent {
|
|||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
isSelected(id:string, set:Set<string>) {
|
||||
return set.has(id);
|
||||
}
|
||||
|
||||
/*
|
||||
isSelectedWrong(id:string) {
|
||||
return this.selectedWrong.has(id);
|
||||
|
@ -468,14 +438,8 @@ export class ClaimsByTokenComponent {
|
|||
}
|
||||
|
||||
cancelEditOfCuration(claim: any) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if(claim.approved) {
|
||||
//this.selectedRight_CuratedMode.add(claim.id);
|
||||
|
@ -485,18 +449,11 @@ export class ClaimsByTokenComponent {
|
|||
//this.selectedWrong_CuratedMode.add(claim.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
saveEdited(claim: any, editable_index: number) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.curated_status = this.errorCodes.LOADING;
|
||||
|
||||
|
@ -527,18 +484,11 @@ export class ClaimsByTokenComponent {
|
|||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
saveChanges() {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.pending_status = this.errorCodes.LOADING;
|
||||
//this.openLoading();
|
||||
|
@ -558,25 +508,17 @@ export class ClaimsByTokenComponent {
|
|||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
clearCheckboxes() {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.pending_status = this.errorCodes.LOADING;
|
||||
this.selectedRight_PendingMode.clear();
|
||||
this.selectedWrong_PendingMode.clear();
|
||||
this.pending_status = this.errorCodes.DONE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public openLoading(){
|
||||
|
@ -584,7 +526,6 @@ export class ClaimsByTokenComponent {
|
|||
this.loading.open();
|
||||
}
|
||||
}
|
||||
|
||||
public closeLoading(){
|
||||
if(this.loading){
|
||||
this.loading.close();
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {Component, ViewChild, Input} from '@angular/core';
|
||||
import {Location} from '@angular/common';
|
||||
import {Observable} from 'rxjs';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {ModalLoading} from '../../utils/modal/loading.component';
|
||||
import {AlertModal} from '../../utils/modal/alert';
|
||||
import {Session} from '../../login/utils/helper.class';
|
||||
import {EnvProperties} from '../../utils/properties/env-properties';
|
||||
import {MailPrefsService} from './mailPrefs.service';
|
||||
|
@ -8,7 +11,6 @@ import {ConnectHelper} from '../connectHelper';
|
|||
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
||||
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
|
||||
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
||||
import {UserManagementService} from "../../services/user-management.service";
|
||||
|
||||
declare var UIkit: any;
|
||||
|
||||
|
@ -32,6 +34,7 @@ export class MailPrefsComponent {
|
|||
//public showForbiddenMessage:boolean = false;
|
||||
public userValidMessage:string = "";
|
||||
public savedMessage: string = "";
|
||||
|
||||
public fetchId:string;
|
||||
|
||||
private errorCodes: ErrorCodes;
|
||||
|
@ -39,10 +42,7 @@ export class MailPrefsComponent {
|
|||
|
||||
@Input() showSaveResetButtons: boolean = true;
|
||||
|
||||
constructor(private _mailPrefsService: MailPrefsService,
|
||||
private route: ActivatedRoute, private _router: Router,
|
||||
private location: Location,
|
||||
private userManagementService: UserManagementService) {
|
||||
constructor (private _mailPrefsService: MailPrefsService, private route: ActivatedRoute, private _router:Router, private location: Location) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.errorMessages = new ErrorMessagesComponent();
|
||||
this.status = this.errorCodes.LOADING;
|
||||
|
@ -57,26 +57,21 @@ export class MailPrefsComponent {
|
|||
if(!this.communityId) {
|
||||
this.communityId = params['communityId'];
|
||||
}
|
||||
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
|
||||
this.fetchId = user.email;
|
||||
|
||||
this.fetchId = Session.getUserEmail();
|
||||
|
||||
this.getEmailPreferences();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
getEmailPreferences() {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
this.status = this.errorCodes.LOADING;
|
||||
|
@ -125,20 +120,13 @@ export class MailPrefsComponent {
|
|||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
changeNotify(notification: any, checked: boolean, index: number) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
this.savedMessage = "";
|
||||
|
@ -146,20 +134,13 @@ export class MailPrefsComponent {
|
|||
notification.notify = checked;
|
||||
this.prefsChanged[index] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
changeFrequency(index: number) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
this.savedMessage = "";
|
||||
|
@ -168,21 +149,14 @@ export class MailPrefsComponent {
|
|||
this.prefsChanged[index] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
saveNotification(index: number) {
|
||||
if(this.notifications.length > 0 && this.initialNotifications.length > 0) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
if(JSON.stringify(this.notifications[index]) != JSON.stringify(this.initialNotifications[index])) {
|
||||
|
@ -210,7 +184,8 @@ export class MailPrefsComponent {
|
|||
this.status = this.errorCodes.NOT_SAVED;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*UIkit.notification({
|
||||
message : '<strong>No changes selected for '+this.notifications[index].openaireName+' email preferences<strong>',
|
||||
status : 'primary',
|
||||
|
@ -220,21 +195,14 @@ export class MailPrefsComponent {
|
|||
this.savedMessage = "Notification settings for claims saved!";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
restoreNotification(index: number) {
|
||||
this.userManagementService.isLoggedIn(this.properties.userInfoUrl).subscribe(isLoggedIn => {
|
||||
if (!isLoggedIn) {
|
||||
if(!Session.isLoggedIn()){
|
||||
//this.userValidMessage = "User session has expired. Please login again.";
|
||||
if(this.showSaveResetButtons) {
|
||||
this._router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
"errorCode": LoginErrorCodes.NOT_VALID,
|
||||
"redirectUrl": this._router.url
|
||||
}
|
||||
});
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
}
|
||||
} else {
|
||||
if(this.notifications.length > 0 && this.initialNotifications.length > 0) {
|
||||
|
@ -245,9 +213,7 @@ export class MailPrefsComponent {
|
|||
this.prefsChanged[index] = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
prefsChanged(index: number) : boolean {
|
||||
if(this.notifications.length > 0 && this.initialNotifications.length > 0) {
|
||||
|
|
|
@ -1,47 +1,31 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import {
|
||||
Router,
|
||||
CanActivate,
|
||||
ActivatedRouteSnapshot,
|
||||
RouterStateSnapshot,
|
||||
Route,
|
||||
CanLoad,
|
||||
UrlSegment
|
||||
} from '@angular/router';
|
||||
import {Observable} from 'rxjs';
|
||||
import {Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Route, CanLoad} 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 {CommunityService} from "../connect/community/community.service";
|
||||
import {UserManagementService} from "../services/user-management.service";
|
||||
import {EnvironmentSpecificService} from "../utils/properties/environment-specific.service";
|
||||
|
||||
@Injectable()
|
||||
export class LoginGuard implements CanActivate {
|
||||
export class LoginGuard implements CanActivate, CanLoad {
|
||||
|
||||
constructor(private router: Router,
|
||||
private userManagementService: UserManagementService,
|
||||
private propertiesService: EnvironmentSpecificService) {
|
||||
constructor(private router: Router) {
|
||||
}
|
||||
|
||||
check(path: string): Observable<boolean> |boolean {
|
||||
const loggedIn = this.propertiesService.subscribeEnvironment().pipe(mergeMap(properties => {
|
||||
return this.userManagementService.isLoggedIn(properties['userInfoUrl']).pipe(map( isLoggedIn => {
|
||||
return isLoggedIn;
|
||||
}));
|
||||
}));
|
||||
loggedIn.pipe(filter( isLoggedIn => !isLoggedIn)).subscribe( () => {
|
||||
this.router.navigate(['/user-info'], {
|
||||
queryParams: {
|
||||
'errorCode': LoginErrorCodes.NOT_LOGIN,
|
||||
'redirectUrl': path
|
||||
check(path: string): boolean {
|
||||
let loggedIn = false;
|
||||
if (Session.isLoggedIn()) {
|
||||
loggedIn = true;
|
||||
}
|
||||
if (!loggedIn) {
|
||||
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, path}});
|
||||
}
|
||||
});
|
||||
});
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
return this.check(state.url);
|
||||
}
|
||||
|
||||
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.check('/' + route.path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,21 +51,18 @@ export class UserComponent {
|
|||
this.userManagementsService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
||||
this.user = user;
|
||||
this.loggedIn = !!this.user;
|
||||
});
|
||||
this.errorMessage = "";
|
||||
this.sub = this.route.queryParams.subscribe(params => {
|
||||
this.errorCode = params["errorCode"];
|
||||
this.redirectUrl = params["redirectUrl"];
|
||||
this.userManagementsService.getUserInfo(this.properties.userInfoUrl).subscribe( user => {
|
||||
this.user = user;
|
||||
this.loggedIn = !!this.user;
|
||||
});
|
||||
this.errorMessage = "";
|
||||
if (this.loggedIn && this.errorCode == '1') {
|
||||
this.redirect();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.sub.unsubscribe();
|
||||
if (this.sublogin) {
|
||||
|
@ -74,7 +71,7 @@ export class UserComponent {
|
|||
}
|
||||
|
||||
redirect() {
|
||||
if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != ""){
|
||||
if (this.redirectUrl && this.redirectUrl != "") {
|
||||
this.redirectUrl = decodeURIComponent(this.redirectUrl);
|
||||
var baseUrl = this.redirectUrl;
|
||||
var queryParams = "";
|
||||
|
@ -101,7 +98,7 @@ export class UserComponent {
|
|||
}
|
||||
|
||||
logIn() {
|
||||
if(this.redirectUrl && this.redirectUrl != null && this.redirectUrl != ""){
|
||||
if (this.redirectUrl && this.redirectUrl != "") {
|
||||
this.redirectUrl = decodeURIComponent(this.redirectUrl);
|
||||
var baseUrl = this.redirectUrl;
|
||||
var queryParams = "";
|
||||
|
@ -119,6 +116,7 @@ export class UserComponent {
|
|||
|
||||
window.location.href = this.properties.loginUrl;
|
||||
}
|
||||
|
||||
getTheRolesFormatted(roles: string[]) {
|
||||
let formattedRoles = [];
|
||||
for (let role of roles) {
|
||||
|
@ -130,6 +128,7 @@ export class UserComponent {
|
|||
}
|
||||
return formattedRoles.join(", ");
|
||||
}
|
||||
|
||||
isUserManager() {
|
||||
return Session.isUserManager(this.user);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue