File tree Expand file tree Collapse file tree 7 files changed +33
-15
lines changed
Expand file tree Collapse file tree 7 files changed +33
-15
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ import { IotDevicesModule } from './iot-devices/iot-devices.module';
1515import { SharedModule } from '@shared/shared.module' ;
1616import { FontAwesomeModule } from '@fortawesome/angular-fontawesome' ;
1717import { DirectivesModule } from '@shared/directives/directives.module' ;
18- import { HttpClientModule } from '@angular/common/http' ;
1918import { NGMaterialModule } from '@shared/Modules/materiale.module' ;
2019import { BulkImportComponent } from './bulk-import/bulk-import.component' ;
2120import { DeleteDialogComponent } from '@shared/components/delete-dialog/delete-dialog.component' ;
@@ -44,7 +43,6 @@ import { DeleteDialogComponent } from '@shared/components/delete-dialog/delete-d
4443 IotDevicesModule ,
4544 DatatargetModule ,
4645 DirectivesModule ,
47- HttpClientModule ,
4846 FormModule ,
4947 SharedModule ,
5048 FontAwesomeModule ,
Original file line number Diff line number Diff line change 2525 < button class ="btn btn-primary " type ="submit " [disabled] ="!authForm.valid "> {{'Login'}}</ button >
2626 </ div >
2727 </ form >
28+ < a class ="btn btn-secondary mt-4 " href ="{{getKombitLoginUrl()}} "> {{'AUTH.KOMBIT-BUTTON' | translate}}</ a >
2829 </ div >
2930</ div >
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { NgForm } from '@angular/forms';
33import { AuthService } from './auth.service' ;
44import { Router } from '@angular/router' ;
55import { TranslateService } from '@ngx-translate/core' ;
6+ import { environment } from '@environments/environment' ;
67
78@Component ( {
89 selector : 'app-auth' ,
@@ -21,9 +22,15 @@ export class AuthComponent implements OnInit {
2122 constructor (
2223 private authService : AuthService ,
2324 private router : Router ,
24- public translate : TranslateService , ) { }
25+ public translate : TranslateService
26+ ) { }
2527
26- ngOnInit ( ) : void { }
28+ ngOnInit ( ) : void { }
29+
30+ getKombitLoginUrl ( ) {
31+ const frontpage = encodeURI ( window . location . origin + '/dashboard' ) ;
32+ return `${ environment . baseUrl } auth/kombit/login?redirect=${ frontpage } ` ;
33+ }
2734
2835 onSwitchMode ( ) {
2936 this . isLoginMode = ! this . isLoginMode ;
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export class AuthService {
4949 return this . restService . get ( 'auth/me' ) ;
5050 }
5151
52- private setSession ( jwt : string ) {
52+ setSession ( jwt : string ) {
5353 localStorage . setItem ( 'id_token' , jwt ) ;
5454 }
5555
Original file line number Diff line number Diff line change 11import { Component , OnInit } from '@angular/core' ;
2+ import { ActivatedRoute , Router } from '@angular/router' ;
3+ import { AuthService } from '@auth/auth.service' ;
24
35@Component ( {
46 selector : 'app-dashboard' ,
57 templateUrl : './dashboard.component.html' ,
6- styleUrls : [ './dashboard.component.scss' ]
8+ styleUrls : [ './dashboard.component.scss' ] ,
79} )
810export class DashboardComponent implements OnInit {
9-
10- constructor ( ) { }
11-
12- ngOnInit ( ) : void {
11+ constructor (
12+ private route : ActivatedRoute ,
13+ private authService : AuthService ,
14+ private router : Router
15+ ) {
16+ this . route . queryParams . subscribe ( ( params ) => {
17+ const jwt = params [ 'jwt' ] ;
18+ if ( jwt ) {
19+ this . authService . setSession ( jwt ) ;
20+ // Clear the URL from the parameter
21+ this . router . navigate ( [ '/dashboard' ] ) ;
22+ }
23+ } ) ;
1324 }
1425
26+ ngOnInit ( ) : void { }
1527}
Original file line number Diff line number Diff line change @@ -4,11 +4,9 @@ import {
44 HttpRequest ,
55 HttpHandler ,
66 HttpInterceptor ,
7- HttpErrorResponse ,
87} from '@angular/common/http' ;
9- import { Observable , throwError } from 'rxjs' ;
10- import { retry , catchError } from 'rxjs/operators' ;
11- import { environment } from '../../../environments/environment.prod' ;
8+ import { Observable } from 'rxjs' ;
9+ import { environment } from '../../../environments/environment' ;
1210
1311@Injectable ( )
1412export class AuthJwtInterceptor implements HttpInterceptor {
@@ -18,6 +16,7 @@ export class AuthJwtInterceptor implements HttpInterceptor {
1816 ) : Observable < HttpEvent < any > > {
1917 // If we're not calling the baseurl skip this. Is there a better way?
2018 if ( req . url . indexOf ( environment . baseUrl ) != 0 ) {
19+ console . warn ( "Skip adding Bearer since we're not calling baseUrl ..." ) ;
2120 return next . handle ( req ) ;
2221 }
2322
Original file line number Diff line number Diff line change 639639 },
640640 "AUTH" : {
641641 "EMAIL" : " Email" ,
642- "PASSWORD" : " Adgangskode"
642+ "PASSWORD" : " Adgangskode" ,
643+ "KOMBIT-BUTTON" : " Login med KOMBIT Adgangsstyring"
643644 },
644645 "DASHBOARD" : {
645646 "WELCOME" : " Velkommen til OS2IoT" ,
You can’t perform that action at this time.
0 commit comments