Skip to content

Commit

Permalink
#168 Allow Oauth2 login from any path
Browse files Browse the repository at this point in the history
  • Loading branch information
qligier committed Sep 2, 2024
1 parent 3e65760 commit 6fdad65
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component } from '@angular/core';
import { FhirConfigService } from './fhirConfig.service';
import { TranslateService } from '@ngx-translate/core';
import { Router } from '@angular/router';

@Component({
selector: 'app-root',
Expand All @@ -10,11 +11,23 @@ import { TranslateService } from '@ngx-translate/core';
export class AppComponent {
constructor(
translateService: TranslateService,
fhirConfigService: FhirConfigService
fhirConfigService: FhirConfigService,
router: Router,
) {
translateService.setDefaultLang('de');
translateService.use(translateService.getBrowserLang());

// When the user loads the front page and there is an OAuth token in the URL, redirect to the Mag page
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has('code') && urlParams.has('state')) {
router.navigate(['/mag'], {
queryParams: {
code: urlParams.get('code'),
state: urlParams.get('state'),
},
});
}

let base = location.origin + location.pathname;
if (base.endsWith('/')) {
base += 'fhir';
Expand Down

0 comments on commit 6fdad65

Please sign in to comment.