mirror of
https://github.com/sartography/cr-connect-bpmn.git
synced 2025-02-03 12:23:25 +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 {Router} from '@angular/router';
|
||||||
import {ApiService, isSignedIn, User} from 'sartography-workflow-lib';
|
import {ApiService, AppEnvironment, isSignedIn, User, UserParams} from 'sartography-workflow-lib';
|
||||||
|
|
||||||
interface NavItem {
|
interface NavItem {
|
||||||
path?: string;
|
path?: string;
|
||||||
@ -19,11 +19,11 @@ interface NavItem {
|
|||||||
export class NavbarComponent {
|
export class NavbarComponent {
|
||||||
navLinks: NavItem[];
|
navLinks: NavItem[];
|
||||||
user: User;
|
user: User;
|
||||||
isSignedIn = isSignedIn;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private api: ApiService,
|
private api: ApiService,
|
||||||
|
@Inject('APP_ENVIRONMENT') private environment: AppEnvironment,
|
||||||
) {
|
) {
|
||||||
this._loadUser();
|
this._loadUser();
|
||||||
}
|
}
|
||||||
@ -39,7 +39,14 @@ export class NavbarComponent {
|
|||||||
this._loadNavLinks();
|
this._loadNavLinks();
|
||||||
}, error => {
|
}, error => {
|
||||||
localStorage.removeItem('token');
|
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.
|
// For testing purposes, create a user to simulate login.
|
||||||
if (!this.environment.production) {
|
if (!this.environment.production) {
|
||||||
this.model.redirect_url = location.origin + '/session';
|
localStorage.setItem('prev_url', location.href);
|
||||||
this.api.redirectToLogin(location.href, this.model);
|
this.api.redirectToLogin(location.origin + '/session', this.model);
|
||||||
} else {
|
} else {
|
||||||
this.error = new Error('This feature does not work in production.');
|
this.error = new Error('This feature does not work in production.');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user