Commit 74588c61 authored by Lukas Burgey's avatar Lukas Burgey

Use a cookie to set idp preference

parent 0dd7504c
...@@ -19,10 +19,14 @@ export class LoginComponent { ...@@ -19,10 +19,14 @@ export class LoginComponent {
public dialog: DialogService, public dialog: DialogService,
public http: HttpClient, public http: HttpClient,
) { ) {
this.selectedIdP = this.userService.getIdPPreference();
this.userService.getAuthInfo().subscribe( this.userService.getAuthInfo().subscribe(
data => { data => {
this.idps = data['idps']; this.idps = data['idps'];
this.selectedIdP = data['default']; if (!this.selectedIdP) {
this.selectedIdP = data['default'];
}
} }
); );
} }
......
...@@ -91,19 +91,12 @@ export class UserService { ...@@ -91,19 +91,12 @@ export class UserService {
); );
} }
public backendOperational(): Observable<boolean> { public setIdPPreference(idpId: number) {
return this.http.get('/backend/api/operational').map( this.cookieService.set('idp_id', String(idpId));
(data) => {
return data['operational'];
},
(err) => {
return false;
}
);
} }
public login(idpId: number) { public getIdPPreference(): number {
window.location.href = 'https://hdf-portal.data.kit.edu/backend/auth/v1/request/?idp=' + idpId; return Number(this.cookieService.get('idp_id'));
} }
public updateData(data: any) { public updateData(data: any) {
...@@ -169,6 +162,11 @@ export class UserService { ...@@ -169,6 +162,11 @@ export class UserService {
this.updateState(); this.updateState();
} }
public login(idpId: number) {
this.setIdPPreference(idpId);
window.location.href = 'https://hdf-portal.data.kit.edu/backend/auth/v1/request';
}
public logout() { public logout() {
this.http.post('/backend/auth/v1/logout/', {}).subscribe( this.http.post('/backend/auth/v1/logout/', {}).subscribe(
data => { data => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment