fix for redirect url
This commit is contained in:
parent
d57ce31b52
commit
0c59e9a39c
|
@ -53,7 +53,7 @@ export class HomeComponent implements OnInit {
|
|||
if (this.authService.getIsUserLoggedIn()) {
|
||||
this.router.navigate([pageUrl]);
|
||||
} else {
|
||||
this.authService.redirectUrl = pageUrl;
|
||||
// this.authService.redirectUrl = pageUrl;
|
||||
this.login();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,12 +12,17 @@ export class AuthGuardService implements CanActivate, CanLoad {
|
|||
canActivate (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
|
||||
if ( this.authenticationService.getIsUserLoggedIn() ) { return true; }
|
||||
|
||||
/* If no cookie was found, clear the app's session.
|
||||
The user may have logged out using another OpenAIRE portal */
|
||||
sessionStorage.clear();
|
||||
|
||||
|
||||
// Store the attempted URL for redirecting
|
||||
sessionStorage.setItem('state.location', state.url);
|
||||
if (state.url !== '/join') {
|
||||
/* If no cookie was found, clear the app's session.
|
||||
The user may have logged out using another OpenAIRE portal */
|
||||
sessionStorage.clear();
|
||||
this.authenticationService.redirectUrl = state.url;
|
||||
sessionStorage.setItem('state.location', state.url);
|
||||
}
|
||||
console.log('redirect state: ' + sessionStorage.getItem('state.location'));
|
||||
|
||||
// If we decide that in this case we will send the user back to the aai
|
||||
// this.authenticationService.redirectUrl = state.url;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Router } from '@angular/router';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { environment } from '../../environments/environment';
|
||||
import { deleteCookie, getCookie } from '../domain/utils';
|
||||
|
@ -8,8 +8,7 @@ import { BehaviorSubject } from 'rxjs';
|
|||
@Injectable()
|
||||
export class AuthenticationService {
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
constructor(private router: Router,
|
||||
private http: HttpClient) {}
|
||||
|
||||
private apiUrl: string = environment.API_ENDPOINT;
|
||||
|
@ -18,8 +17,6 @@ export class AuthenticationService {
|
|||
// store the URL so we can redirect after logging in
|
||||
public redirectUrl: string;
|
||||
|
||||
private _storage: Storage = sessionStorage;
|
||||
|
||||
private cookie: string = null;
|
||||
|
||||
public isLoggedIn_ = new BehaviorSubject(false);
|
||||
|
@ -33,7 +30,6 @@ export class AuthenticationService {
|
|||
if (this.redirectUrl) {
|
||||
const url = this.redirectUrl;
|
||||
this.redirectUrl = null;
|
||||
console.log('stored location', url);
|
||||
sessionStorage.setItem('state.location', url);
|
||||
} else {
|
||||
/*sessionStorage.setItem("state.location", this.router.url);*/
|
||||
|
@ -108,7 +104,7 @@ export class AuthenticationService {
|
|||
sessionStorage.removeItem('state.location');
|
||||
console.log(`tried to login - returning to state: ${state}`);
|
||||
if ( !this.getIsUserLoggedIn() ) {
|
||||
// console.log('user hasn\'t logged in yet -- going to home');
|
||||
// console.log('user hasn't logged in yet -- redirecting to home');
|
||||
this.router.navigate(['/home']);
|
||||
} else {
|
||||
this.router.navigate([state]);
|
||||
|
|
|
@ -23,7 +23,7 @@ export class UsagestatsService {
|
|||
|
||||
getReportResponse(page: String, pageSize: String, params: URLSearchParams): Observable<ReportResponseWrapper> {
|
||||
const url = `${this.apiUrl}/sushilite/getReportResults/${page}/${pageSize}?${params}`;
|
||||
console.log(`knocking on: ${url}`);
|
||||
// console.log(`knocking on: ${url}`);
|
||||
|
||||
return this.httpClient.get<ReportResponseWrapper>(url, headerOptions);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue