Commit cbc9b732 authored by Sebastian's avatar Sebastian

OAuth-Login

parent 1909341f
......@@ -71,8 +71,10 @@ import { DatenexportSeiteComponent } from './datenexport-seite/datenexport-seite
import { QuellenAngabeComponent } from './widgets/entry/quellen-angabe/quellen-angabe.component';
import { FormcontrolBlockComponent } from './home/contact/formcontrol-block/formcontrol-block.component';
import { MenubarItemComponent } from './menubar/menubar-item/menubar-item.component';
import { BliIconComponent } from './portal/bli/bli-icon/bli-icon.component';
import { BliIconComponent } from './portal/bli/bli-icon/bli-icon.component';
import { TagComponent } from './widgets/search/tag/tag.component';
import { ElementFilterComponent } from './widgets/element-filter/element-filter.component';
enableProdMode();
......@@ -135,7 +137,7 @@ enableProdMode();
MenubarItemComponent,
BliIconComponent,
TagComponent,
//MatAutocompleteModule,
ElementFilterComponent
],
imports: [
BrowserModule,
......
<ng-container *ngIf="oauth">
<div class="modal-header">
<span *ngIf="authService.loggedIn" class="">Sie wurden per OAuth angemeldet.</span>
<span *ngIf="!authService.loggedIn" class="">Sie werden per OAuth über OSM angemeldet...</span>
<button *ngIf="authService.getCurrentUser() != undefined" type="button" class="close" aria-label="Close" (click)="this.close()"><span aria-hidden="true">&times;</span></button>
<div class="modal-header">
<h4 class="modal-title">Anmelden</h4>
<button type="button" class="close" aria-label="Close"
</div>
<div class="modal-body">
<div class="modal-wrap modaltest">
<div class="modal-wrap">
<div class="container">
<div markdown [src]="'assets/markdown/modal-content/osm-anmeldung.md'" class="">
</div>
In deinem Benutzerprofil in Openstreetmap kannst du jederzeit die Berechtigungen widerrufen. Benutze dazu das Menü in deinen Benutzereinstellungen unter <span *ngIf="authService.getCurrentUser() == undefined">oAuth-Einstellungen</span><a *ngIf="authService.getCurrentUser() != undefined" href="https://www.openstreetmap.org/user/{{authService.getCurrentUser().getDescription()}}/oauth_clients">oAuth-Einstellungen</a> und klicke dort auf "Widerrufen!" neben dem Eintrag zum Geoportal.
</div>
</div>
</div>
</div>
</ng-container>
<ng-container *ngIf="!oauth">
<div class="modal-header">
<h4 class="modal-title">Anmelden</h4>
<button type="button" class="close" aria-label="Close"
(click)="this.close()">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="modal-wrap modaltest">
<div class="modal-wrap">
<div class="container">
</div>
<div class="modal-body">
<div class="modal-wrap modaltest">
<div class="modal-wrap">
<div class="container">
<div *ngIf="!authService.loggedIn" class="">
<div *ngIf="!authService.loggedIn" class="">
<div class="login_ex exclamation">
<i class="fa_ fa-exclamation-triangle_ fa-lg_ gp_warning icon_big" aria-hidden="true">&nbsp;</i>
<p>Nur angemeldete Nutzer*innen können Orte des Guten Lebens
<div class="login_ex exclamation">
<i class="fa_ fa-exclamation-triangle_ fa-lg_ gp_warning icon_big" aria-hidden="true">&nbsp;</i>
<p>Nur angemeldete Nutzer*innen können Orte des Guten Lebens
anlegen und bearbeiten.</p>
</div>
<form [formGroup]="loginForm" (ngSubmit)="login()">
<div class="form-group">
<label for="username">Benutzername</label> <input type="text"
</div>
<form [formGroup]="loginForm" (ngSubmit)="login()">
<div class="form-group">
<label for="username">Benutzername</label> <input type="text"
formControlName="username" class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.username.errors }" />
<div *ngIf="submitted && f.username.errors"
<div *ngIf="submitted && f.username.errors"
class="invalid-feedback">
<div *ngIf="f.username.errors.required">Username is
required</div>
required</div>
</div>
</div>
<!--
<div class="form-group">
<label for="username">E-Mail</label> <input type="text"
formControlName="username" class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.email.errors }" />
<div *ngIf="submitted && f.email.errors" class="invalid-feedback">
<div *ngIf="f.email.errors.required">E-Mail is required</div>
</div>
</div>
-->
<div class="form-group">
<label for="password">Passwort</label> <input type="password"
formControlName="password" class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.password.errors }" />
formControlName="password" class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.password.errors }" />
<div *ngIf="submitted && f.password.errors"
class="invalid-feedback">
<div *ngIf="f.password.errors.required">Password is
required</div>
<div *ngIf="f.password.errors.minlength">Password must be
at least 6 characters</div>
</div>
</div>
<div class="form-check">
<input type="checkbox" formControlName="savelogin"
class="form-check-input"
[ngClass]="{ 'is-invalid': submitted && f.savelogin.errors }" />
<label class="form-check-label" for="savelogin">Eingeloggt
bleiben</label>
class="invalid-feedback">
<div *ngIf="f.password.errors.required">Password is
required</div>
<div *ngIf="f.password.errors.minlength">Password must be
at least 6 characters</div>
</div>
<br>
<button [disabled]="sending && ! authService.loginFailed"
class="btn btn-primary">Anmelden</button>
<div *ngIf="authService.loginFailed">Anmeldung
fehlgeschlagen.</div>
<div class="divider"></div>
<div class="">
Neu beim Geoportal des Guten Lebens? <br /> <br />
<button class="btn btn-secondary" routerLink="/register" (click)="this.close()">Registrieren</button>
</div>
<div class="form-check">
<input type="checkbox" formControlName="savelogin"
class="form-check-input"
[ngClass]="{ 'is-invalid': submitted && f.savelogin.errors }" />
<label class="form-check-label" for="savelogin">Eingeloggt
bleiben</label>
</div>
<br>
<button [disabled]="sending && ! authService.loginFailed"
class="btn btn-primary">Anmelden</button>
<span>&nbsp;</span>
<button type="button" [disabled]="" (click)="apiService.getRequestToken()" class="btn btn-primary">Mit Openstreetmap Anmelden (oAuth)</button>
<div *ngIf="authService.loginFailed">Anmeldung fehlgeschlagen.</div>
<div class="divider"></div>
<div class="">
Neu beim Geoportal des Guten Lebens? <br /> <br />
<div *ngIf="!apiService.registrationAvailable()">
Die Registrierung steht zur Zeit nicht zur Verfügung.
</div>
</form>
<br><br>
<div markdown [src]="'assets/markdown/modal-content/Anmelden.md'" class="d-none"></div>
<a href="https://www.openstreetmap.org/login" target="_blank" class="d-none"><button
class="btn btn-lg btn-outline-primary"
(click)="modalService.open(login,true)">Mit OpenStreetMap
anmelden</button></a>
</div>
<button [disabled]="!apiService.registrationAvailable()" class="btn btn-secondary" routerLink="/register" (click)="this.close()">Registrieren</button>
</div>
</form>
<br><br>
<div markdown [src]="'assets/markdown/modal-content/Anmelden.md'" class=""></div>
</div>
<div *ngIf="authService.loggedIn" class="">
<div>Sie sind eingeloggt.</div>
</div>
<div *ngIf="authService.loggedIn" class="">
<div>Sie sind eingeloggt.</div>
</div>
</div>
</div>
</div>
<div *ngIf="!authService.loggedIn" class="modal-footer">
<a href="https://www.openstreetmap.org/user/new" target="_blank"><button
</div>
</div>
<div *ngIf="!authService.loggedIn" class="modal-footer">
<a href="https://www.openstreetmap.org/user/new" target="_blank"><button
type="button" class="btn btn-primary" ngbAutofocus>Bei
Openstreetmap registrieren</button></a>
</div>
Openstreetmap registrieren</button></a>
</div>
</ng-container>
\ No newline at end of file
......@@ -22,27 +22,31 @@ export class AuthComponent implements OnInit {
private message: string;
private sending: boolean;
private loginForm: FormGroup;
private oauth = false;
constructor(
private logger: LogService,
private authService: AuthService,
private formBuilder: FormBuilder,
private router: Router,
private modalService: ModalManagerService,
private apiService: GeoportalApiService,
private activeRoute: ActivatedRoute,
) {
this.logger.debug('AuthComponent instantiated.');
this.loginForm = this.formBuilder.group({
username: ['', Validators.required],
password: ['', [Validators.required, Validators.minLength(6)]],
savelogin: ['']
});
this.logger.debug("Getting current route.");
this.activeRoute.firstChild.params.subscribe(
(params)=>{
this.routeParams = params;
if(this.routeParams['rt']){
this.oauth = true;
this.authService.loginWithToken(this.routeParams['rt']);
}
this.logger.debug("Route: "+JSON.stringify(params,null,3));
}
);
......@@ -52,7 +56,6 @@ export class AuthComponent implements OnInit {
return this.loginForm.controls;
}
login() {
this.sending = true;
this.logger.debug('authComponent: ' + this.loginForm.value.username);
......
......@@ -31,7 +31,7 @@
<div ngbDropdown class="dropdown" *ngIf="authService.loggedIn">
<button ngbDropdownToggle class="btn btn-light buttonicon profile" type="button"
id="profilMenuButton">{{authService.currentUser.username}}</button>
id="profilMenuButton">{{authService.getUsername()}}</button>
<div ngbDropdownMenu class="dropdown-menu" aria-labelledby="profilMenuButton">
<a class="dropdown-item" (click)="logout()">Logout</a>
</div>
......
import { BliDimension } from './BliDimension';
export class BliDimensionFactory{
static dimensions : Array<BliDimension>;
static init(){
static init(){
console.log("Creating empty array for bli-dimensions.");
BliDimensionFactory.dimensions = new Array<BliDimension>();
}
static getDimensionById(id:number){
for(let dim of BliDimensionFactory.dimensions){
if(dim.id == id){
return dim;
}
}
return undefined;
}
static add(dim:BliDimension){
for(let d of BliDimensionFactory.dimensions){
if(d.id == dim.id || d.name == dim.name){
console.log("Warning: Dimension " +dim.name + " already exists. (" + d.id+":"+d.name +"/"+dim.id+":"+dim.name +")");
return;
static getDimensionByName(name:string){
for(let dim of BliDimensionFactory.dimensions){
if(dim.name == name){
return dim;
}
}
BliDimensionFactory.dimensions.push(dim);
return undefined;
}
static create(data:any) : BliDimension{
if(data instanceof BliDimension){
let dim = BliDimensionFactory.getDimensionById(data.id);
if(dim === null){
BliDimensionFactory.add(data);
return data;
}else{
let existing = BliDimensionFactory.getDimensionById(data.id);
existing.update(data);
return;
}
static add(dim:BliDimension) : boolean{
if(dim == null || dim == undefined){
return false;
}
let id:number;
if(data['id']){
id=data['id']*1;
}else{
if(!isNaN(parseFloat(data)) && !isNaN(data - 0)){
id=data*1;
}else{
return null;
}
if(BliDimensionFactory.getDimensionByName(dim.name)){
return false;
}
if(BliDimensionFactory.getDimensionById(dim.id)){
return false;
}
let dim = BliDimensionFactory.getDimensionById(id);
if(dim != null){
dim.update(data);
console.log("Pushing to array: " +dim.name+"/"+dim.id);
BliDimensionFactory.dimensions.push(dim);
return true;
}
static get(data){
let dim = undefined;
if(data.id){
dim = BliDimensionFactory.getDimensionById(data.id);
}
if(dim != undefined){
return dim;
}
if(data.name){
dim = BliDimensionFactory.getDimensionByName(data.name);
}
return dim;
}
static create(data:any) : BliDimension{
if(typeof data == "number"){
data = {"id":data};
}
let existing = BliDimensionFactory.get(data);
if(existing === undefined){
let newDim = new BliDimension(data);
console.log("Creating new dimension: "+JSON.stringify(data));
BliDimensionFactory.add(newDim);
return newDim;
}else{
dim = new BliDimension(data);
if(dim.isValid()){
BliDimensionFactory.add(dim);
return dim;
}else{
return null;
}
existing.update(data);
return existing;
}
}
}
......
......@@ -12,7 +12,7 @@ export class User {
description: string;
isAdmin: boolean = false;
isRedakteur: boolean = false;
oauthToken : string ="";
clear():void{
this.id = -1;
......@@ -40,6 +40,12 @@ export class User {
}
return false;
}
setOAuthToken(token:string){
this.oauthToken=token;
}
hasOAuthToken(){
return this.oauthToken != "";
}
setData(data:any){
......@@ -77,7 +83,16 @@ export class User {
this.isAdmin = this.hasRole('admin');
this.isRedakteur = this.hasRole('redakteur');
}
getUsername(){
if(this.hasOAuthToken() && this.username.startsWith('osm:')){
return this.description;
}else{
return this.username;
}
}
getDescription(){
return this.description;
}
toString(): string {
let msg: string = "Username: " + this.username;
......
......@@ -4,5 +4,5 @@
<button class="btn ol-zoomInButton zoombtn" (click)="zoomIn()">+</button>
<button class="btn ol-zoomOutButton zoombtn" (click)="zoomOut()">-</button>
<app-element-filter></app-element-filter>
</div>
<div class="list-group-item">
<div class="bliicon2 bliicon-housing">
<div class="bliicon2 {{this.iconclass}}">
<div *ngIf="displayType=='icons_and_labels'">
<ng-content></ng-content>
{{dimension}}
</div>
</div>
</div>
\ No newline at end of file
import { Component, OnInit, Input } from '@angular/core';
import { BliService } from '../../../services/bli.service';
@Component({
selector: 'app-bli-icon',
templateUrl: './bli-icon.component.html',
styleUrls: ['./bli-icon.component.css']
})
export class BliIconComponent implements OnInit {
export class BliIconComponent implements OnInit {
@Input() displayType: string;
constructor() { }
@Input() dimension: string;
iconclass : string;
constructor(private bliService: BliService) {
}
ngOnInit() {
this.iconclass = this.bliService.getIconClass(this.dimension).split(' ')[1];
}
}
......@@ -11,44 +11,31 @@
<!-- Icons (alle dimensionen von node)-->
<div *ngIf="displayType=='icons' || displayType=='icons_and_labels'" class="bli-icons">
<div class="list-group">
<app-bli-icon *ngIf="hasDimension(node,'Wohnbedingungen')" [displayType]="displayType">
Wohnbedingungen
<app-bli-icon [dimension]="'Wohnbedingungen'" *ngIf="hasDimension(node,'Wohnbedingungen')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Gemeinschaft')" [displayType]="displayType">
Gemeinschaft
<app-bli-icon [dimension]="'Gemeinschaft'" *ngIf="hasDimension(node,'Gemeinschaft')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Bildung')" [displayType]="displayType">
Bildung
<app-bli-icon [dimension]="'Bildung'" *ngIf="hasDimension(node,'Bildung')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Gesundheit')" [displayType]="displayType">
Gesundheit
<app-bli-icon [dimension]="'Gesundheit'" *ngIf="hasDimension(node,'Gesundheit')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Einkommen')" [displayType]="displayType">
Einkommen
<app-bli-icon [dimension]="'Einkommen'" *ngIf="hasDimension(node,'Einkommen')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Infrastruktur')" [displayType]="displayType">
Infrastruktur
<app-bli-icon [dimension]="'Infrastruktur'" *ngIf="hasDimension(node,'Infrastruktur')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Freizeit und Kultur')" [displayType]="displayType">
Freizeit und Kultur
<app-bli-icon [dimension]="'Freizeit und Kultur'" *ngIf="hasDimension(node,'Freizeit und Kultur')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Umwelt')" [displayType]="displayType">
Umwelt
<app-bli-icon [dimension]="'Umwelt'" *ngIf="hasDimension(node,'Umwelt')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Zufriedenheit')" [displayType]="displayType">
Zufriedenheit
<app-bli-icon [dimension]="'Zufriedenheit'" *ngIf="hasDimension(node,'Zufriedenheit')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Sicherheit')" [displayType]="displayType">
Sicherheit
<app-bli-icon [dimension]="'Sicherheit'" *ngIf="hasDimension(node,'Sicherheit')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Arbeit')" [displayType]="displayType">
Arbeit
<app-bli-icon [dimension]="'Arbeit'" *ngIf="hasDimension(node,'Arbeit')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Engagement/Beteiligung')" [displayType]="displayType">
Engagement/Beteiligung
<app-bli-icon [dimension]="'Engagement/Beteiligung'" *ngIf="hasDimension(node,'Engagement/Beteiligung')" [displayType]="displayType">
</app-bli-icon>
<app-bli-icon *ngIf="hasDimension(node,'Work-Life-Balance')" [displayType]="displayType">
Work-Life-Balance
<app-bli-icon [dimension]="'Work-Life-Balance'" *ngIf="hasDimension(node,'Work-Life-Balance')" [displayType]="displayType">
</app-bli-icon>
</div>
</div>
......
<div class="widget-wrap">
<h4>Jetzt registrieren</h4>
<div *ngIf="!(apiService.registrationAvailable())">Die Registrierung steht zur Zeit nicht zur Verfügung.</div>
<form [formGroup]="registerForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="username">Benutzername</label> <input type="text"
formControlName="username" class="form-control"
......@@ -9,6 +12,7 @@
<div *ngIf="f.username.errors.required">Username is required</div>
</div>
</div>
<div class="form-group">
<label for="password">Passwort</label> <input type="password"
formControlName="password" class="form-control"
......@@ -19,6 +23,7 @@
least 6 characters</div>
</div>
</div>
<div class="form-group">
<label for="email">E-Mail</label> <input type="text"
formControlName="email" class="form-control"
......@@ -27,6 +32,7 @@
<div *ngIf="f.email.errors.required">E-Mail is required</div>
</div>
</div>
<div class="form-group">
<label for="firstname">Vorname</label> <input type="text"
formControlName="firstname" class="form-control"
......@@ -36,6 +42,7 @@
required</div>
</div>
</div>
<div class="form-group">
<label for="lastname">Nachname</label> <input type="text"
formControlName="lastname" class="form-control"
......@@ -44,23 +51,22 @@
<div *ngIf="f.lastname.errors.required">Last Name is required</div>
</div>
</div>
<div class="form-group">
<label for="description">Beschreibung</label>
<textarea formControlName="description" class="form-control"
[ngClass]="{ 'is-invalid': submitted && f.description.errors }"></textarea>
<div *ngIf="submitted && f.description.errors"
class="invalid-feedback">
<div *ngIf="f.description.errors.required">Description is
required</div>
<div *ngIf="f.description.errors.required">Description is required</div>
</div>
</div>
<div class="form-group">
<button [disabled]="loading" class="btn btn-primary">Registrieren</button>
<button [disabled]="loading||!apiService.registrationAvailable()" class="btn btn-primary">Registrieren</button>
<img *ngIf="loading"
src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
<button [routerLink]="['/login']" class="btn btn-secondary">Abrechen</button>
<!--<a [routerLink]="['/login']" class="btn btn-link">Abbrechen</a>-->
<button [routerLink]="['/login']" class="btn btn-secondary">Abrechen</button>
</div>
<div class="form-group">{{message}}</div>
</form>
</div>
......@@ -37,6 +37,24 @@ export class RegisterComponent implements OnInit {
lastname: ['user'],
description: ['description']
});
this.apiService.checkRegistrationAvailabilty().subscribe(
(data)=>{
if(data.status == 503){
console.log("disabling registerform");
this.registerForm.disable();
}else{
console.log("Not disabling registerform");
}
},
(error)=>{
if(error.status == 503){
console.log("disabling registerform");
this.registerForm.disable();
}else{
console.log("Not disabling registerform");
}
},
);
}
// convenience getter for easy access to form fields
......@@ -51,6 +69,7 @@ export class RegisterComponent implements OnInit {
return;
} else {
this.loading = true;
this.apiService.registerUser(this.registerForm.value as User)
.pipe(
tap(data => this.logger.debug('fetched some data: ' + JSON.stringify(data))),
......
......@@ -52,6 +52,18 @@ export class AuthService {
);
}
loginWithToken(token:string) {
return this.apiService.loginWithToken(token)
.subscribe(
response => {
this.handleTokenLoginResponse(response,true,token);
},
error => {
this.handleLoginError();
}
);
}
logout() {
this.profileRetrieved = false;
this.loggedIn = false;
......@@ -71,11 +83,16 @@ export class AuthService {
this.logger.debug("Bearer saved.");
}
getCurrentUser(): User {
return this.currentUser;
}
getUsername(){
if(this.currentUser){
return this.currentUser.getUsername();
}else{
return "";
}
}
isLoggedIn(): boolean {
return this.loggedIn;
......@@ -125,7 +142,25 @@ export class AuthService {
}
);
}
private handleTokenLoginResponse(response: any, saveLogin: boolean,token:string){
if (!response['Bearer']) {
return;
}
this.bearer = response['Bearer'];
this.loggedIn = true;
this.loginFailed = false;
this.currentUser = new User(response);
this.currentUser.setOAuthToken(token);
this.apiService.setBearer(this.bearer);
this.apiService.getCurrentUser().subscribe(
res => {
this.handleUserResponse(res);
this.checkAndExecuteLoginSave(saveLogin);
}
);
}
private handleUserResponse(response: any){
console.log("Userdata:" + JSON.stringify(response, null, 3));
this.currentUser.setData(response);
......
......@@ -66,10 +66,6 @@ export class BliService {
let expires = new Date();
expires.setDate(expires.getDate() + 1);
if (this.cache.has("blidimensions")) {
this.logger.debug("BliService: returning cached version.");
this.parseResponse(this.cache.get("blidimensions"));
} else {
this.logger.debug("BliService: Reading bli-dimensions from server.");
this.apiService.getBliDimensions().subscribe(
(response) => {
......@@ -80,13 +76,9 @@ export class BliService {
this.logger.debug("BliService: Failed to get bli dimensions from server." + JSON.stringify(error));
this.logger.notify('error', 'failed to read bli-dimensions');
});
}
}
parseResponse(response: any) {
this.logger.debug("BliService: parsing response.");
this.logger.debug(JSON.stringify(response));
if (isArray(response)) {
this.dimensions.length = 0;
for (let element of response) {
......
import { Injectable } from '@angular/core';
import { LogService } from './log.service';
var localStorage = window.localStorage;
@Injectable({
providedIn: 'root'
})
export class CacheService {