Skip to content

Commit

Permalink
fix: Check if user is logged in layman
Browse files Browse the repository at this point in the history
Directly checking the endpoint without using some variable storing the boolean value
  • Loading branch information
DailisLangovskis authored and raitisbe committed Nov 26, 2021
1 parent b82ee4c commit 93cb3c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
14 changes: 1 addition & 13 deletions projects/hslayers/src/components/add-data/add-data.service.ts
Expand Up @@ -18,7 +18,6 @@ export type DatasetType = 'url' | 'catalogue' | 'file' | 'OWS';
providedIn: 'root',
})
export class HsAddDataService {
isAuthorized = false;
typeSelected: DatasetType;
//Holds reference to data.url.component type selected
urlType: AddDataUrlType;
Expand All @@ -33,18 +32,7 @@ export class HsAddDataService {
public hsConfig: HsConfig,
public hsCommonEndpointsService: HsCommonEndpointsService,
public hsCommonLaymanService: HsCommonLaymanService
) {
const layman = this.hsCommonEndpointsService.endpoints.filter(
(ep) => ep.type == 'layman'
)[0];
if (layman) {
this.hsCommonLaymanService.authChange.subscribe((endpoint: any) => {
this.isAuthorized = endpoint.authenticated;
});
this.isAuthorized =
layman.user !== 'anonymous' && layman.user !== 'browser';
}
}
) {}

addLayer(layer: Layer<Source>, underLayer?: Layer<Source>): void {
if (underLayer) {
Expand Down
Expand Up @@ -315,6 +315,6 @@ export class HsAddDataCommonFileService {
}

isAuthorized(): boolean {
return this.hsAddDataService.isAuthorized;
return this.hsLaymanService.getLaymanEndpoint().authenticated;
}
}
Expand Up @@ -9,7 +9,6 @@ import {

import {Cluster} from 'ol/source';

import {HsAddDataService} from '../../add-data.service';
import {HsAddDataVectorService} from '../vector.service';
import {HsCommonEndpointsService} from '../../../../common/endpoints/endpoints.service';
import {HsLanguageService} from '../../../language/language.service';
Expand Down Expand Up @@ -44,8 +43,7 @@ export class HsAddDataVectorFileComponent implements OnInit, AfterViewInit {
public hsLayerManagerService: HsLayerManagerService,
public hsLayerUtilsService: HsLayerUtilsService,
public hsLayoutService: HsLayoutService,
public hsUtilsService: HsUtilsService,
public hsAddDataService: HsAddDataService
public hsUtilsService: HsUtilsService
) {}
ngAfterViewInit(): void {
this.vectorFileInput = this.hsUploadComponent.getVectorFileInput();
Expand Down Expand Up @@ -139,7 +137,10 @@ export class HsAddDataVectorFileComponent implements OnInit, AfterViewInit {
this.data.saveAvailable = false;
} else {
this.data.saveAvailable = true;
this.data.saveToLayman = this.hsAddDataService.isAuthorized;
this.data.saveToLayman =
this.hsCommonEndpointsService.endpoints.filter(
(ep) => ep.type == 'layman'
)[0].authenticated;
}
//add layman endpoint url as url to allow sync
if (this.data.url == '' && this.data.saveToLayman) {
Expand Down

0 comments on commit 93cb3c7

Please sign in to comment.