[Library]: Add http error codes on errorPage and loginUser.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57438 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
f1a9f98600
commit
bee36bfc13
|
@ -1,7 +1,8 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {Component, Inject, Input, Optional} from '@angular/core';
|
||||
import {Location} from '@angular/common';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {Title, Meta} from '@angular/platform-browser';
|
||||
import {RESPONSE} from "@nguniversal/express-engine/tokens";
|
||||
|
||||
@Component({
|
||||
selector: 'error',
|
||||
|
@ -33,7 +34,8 @@ export class ErrorPageComponent {
|
|||
public page: string;
|
||||
|
||||
constructor (private _location: Location, private _meta: Meta,
|
||||
private _title: Title, private route: ActivatedRoute) {
|
||||
private _title: Title, private route: ActivatedRoute,
|
||||
@Optional() @Inject(RESPONSE) private response: any) {
|
||||
|
||||
var title = "OpenAIRE | Error page";
|
||||
|
||||
|
@ -44,6 +46,8 @@ export class ErrorPageComponent {
|
|||
//this.page = location.href;
|
||||
}
|
||||
ngOnInit() {
|
||||
this.response.statusCode = 404;
|
||||
this.response.statusMessage = '404 - Page not found';
|
||||
this.route.queryParams.subscribe(data => {
|
||||
this.page = data['page'];
|
||||
if (!this.page) {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {Component, Inject, Input, Optional} from '@angular/core';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {Title, Meta} from '@angular/platform-browser';
|
||||
import {Meta, Title} from '@angular/platform-browser';
|
||||
|
||||
import {User, Session} from './utils/helper.class';
|
||||
import {Session, User} from './utils/helper.class';
|
||||
import {RouterHelper} from '../utils/routerHelper.class';
|
||||
|
||||
import {EnvProperties} from '../utils/properties/env-properties';
|
||||
import {UserManagementService} from "../services/user-management.service";
|
||||
import {RESPONSE} from "@nguniversal/express-engine/tokens";
|
||||
|
||||
@Component({
|
||||
selector: 'user',
|
||||
|
@ -32,7 +33,8 @@ export class UserComponent {
|
|||
private route: ActivatedRoute,
|
||||
private _meta: Meta,
|
||||
private _title: Title,
|
||||
private userManagementsService: UserManagementService) {
|
||||
private userManagementsService: UserManagementService,
|
||||
@Optional() @Inject(RESPONSE) private response: any) {
|
||||
|
||||
var title = "OpenAIRE | Login";
|
||||
this._title.setTitle(title);
|
||||
|
@ -58,6 +60,17 @@ export class UserComponent {
|
|||
this.errorMessage = "";
|
||||
if (this.loggedIn && this.errorCode == '1') {
|
||||
this.redirect();
|
||||
} else {
|
||||
if (this.errorCode == '1') {
|
||||
this.response.statusCode = 403;
|
||||
this.response.statusMessage = '403 - Forbidden';
|
||||
} else if (this.errorCode == '2' || this.errorCode == '3' || this.errorCode == '5') {
|
||||
this.response.statusCode = 401;
|
||||
this.response.statusMessage = '401 - Unauthorized';
|
||||
} else {
|
||||
this.response.statusCode = 400;
|
||||
this.response.statusMessage = '400 - Bad Request';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue