mirror of
https://github.com/sartography/cr-connect-bpmn.git
synced 2025-01-24 15:48:54 +00:00
Redirects to login on production if no user found.
This commit is contained in:
parent
198cfd90bb
commit
13b47ba894
@ -1,6 +1,6 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {Component, Inject, OnInit} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {ApiService, isSignedIn, User} from 'sartography-workflow-lib';
|
||||
import {ApiService, AppEnvironment, isSignedIn, User, UserParams} from 'sartography-workflow-lib';
|
||||
|
||||
interface NavItem {
|
||||
path?: string;
|
||||
@ -19,11 +19,11 @@ interface NavItem {
|
||||
export class NavbarComponent {
|
||||
navLinks: NavItem[];
|
||||
user: User;
|
||||
isSignedIn = isSignedIn;
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private api: ApiService,
|
||||
@Inject('APP_ENVIRONMENT') private environment: AppEnvironment,
|
||||
) {
|
||||
this._loadUser();
|
||||
}
|
||||
@ -39,7 +39,14 @@ export class NavbarComponent {
|
||||
this._loadNavLinks();
|
||||
}, error => {
|
||||
localStorage.removeItem('token');
|
||||
this.api.openUrl('/');
|
||||
|
||||
if (this.environment.production) {
|
||||
localStorage.setItem('prev_url', location.href);
|
||||
const emptyUserParams: UserParams = { uid: null };
|
||||
this.api.redirectToLogin(location.origin + '/session', emptyUserParams);
|
||||
} else {
|
||||
this.api.openUrl('/');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ export class SignInComponent implements OnInit {
|
||||
|
||||
// For testing purposes, create a user to simulate login.
|
||||
if (!this.environment.production) {
|
||||
this.model.redirect_url = location.origin + '/session';
|
||||
this.api.redirectToLogin(location.href, this.model);
|
||||
localStorage.setItem('prev_url', location.href);
|
||||
this.api.redirectToLogin(location.origin + '/session', this.model);
|
||||
} else {
|
||||
this.error = new Error('This feature does not work in production.');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user