1
- import { HttpHeaders } from '@angular/common/http' ;
2
- import { Inject , Injectable } from '@angular/core' ;
3
- import { Router } from '@angular/router' ;
4
- import { APP_CONFIG } from '@project-lib/app-config' ;
1
+ import { HttpHeaders } from '@angular/common/http' ;
2
+ import { Inject , Injectable } from '@angular/core' ;
3
+ import { Router } from '@angular/router' ;
4
+ import { APP_CONFIG } from '@project-lib/app-config' ;
5
5
6
6
import {
7
7
CoreAuthModule ,
@@ -18,20 +18,20 @@ import {
18
18
GetTokenCommand ,
19
19
GetCurrentUserCommand ,
20
20
} from '@project-lib/core/auth' ;
21
- import { SignUpAdapter } from '@project-lib/core/auth/adapters/signup-adapter.service' ;
22
- import { CreateExternalUserCommand } from '@project-lib/core/auth/commands/create-external-user.command' ;
23
- import { CreateTokenCommand } from '@project-lib/core/auth/commands/create-token.command' ;
21
+ import { SignUpAdapter } from '@project-lib/core/auth/adapters/signup-adapter.service' ;
22
+ import { CreateExternalUserCommand } from '@project-lib/core/auth/commands/create-external-user.command' ;
23
+ import { CreateTokenCommand } from '@project-lib/core/auth/commands/create-token.command' ;
24
24
import {
25
25
AuthTokenSkipHeader ,
26
26
ErrToastSkipHeader ,
27
27
} from '@project-lib/core/constants' ;
28
- import { IAnyObject } from '@project-lib/core/i-any-object' ;
28
+ import { IAnyObject } from '@project-lib/core/i-any-object' ;
29
29
import {
30
30
AnyAdapter ,
31
31
ApiService ,
32
32
UserSessionStoreService ,
33
33
} from '@project-lib/core/index' ;
34
- import { NgxPermissionsService } from 'ngx-permissions' ;
34
+ import { NgxPermissionsService } from 'ngx-permissions' ;
35
35
import {
36
36
Observable ,
37
37
switchMap ,
@@ -66,7 +66,7 @@ export class AuthService {
66
66
private readonly anyAdapter : AnyAdapter ,
67
67
private readonly permissionsService : NgxPermissionsService ,
68
68
@Inject ( APP_CONFIG ) private readonly appConfig : IAnyObject ,
69
- ) { }
69
+ ) { }
70
70
71
71
public isLoggedIn ( ) : Observable < boolean > {
72
72
return this . currentUser ( ) . pipe (
@@ -342,8 +342,26 @@ export class AuthService {
342
342
} ) ,
343
343
) ;
344
344
}
345
+ loginViaKeycloak ( ) : void {
346
+ const form = document . createElement ( 'form' ) ;
347
+ form . method = 'POST' ;
348
+ form . action = `${ this . appConfig . baseApiUrl } ${ this . appConfig . authServiceUrl } /auth/keycloak` ;
349
+ form . style . display = 'none' ;
345
350
351
+ const clientId = document . createElement ( 'input' ) ;
352
+ clientId . type = 'hidden' ;
353
+ clientId . name = 'client_id' ;
354
+ clientId . value = this . appConfig . clientId ;
355
+ form . appendChild ( clientId ) ;
346
356
357
+ const clientSecret = document . createElement ( 'input' ) ;
358
+ clientSecret . type = 'hidden' ;
359
+ clientSecret . name = 'client_secret' ;
360
+ clientSecret . value = this . appConfig . publicKey ;
361
+ form . appendChild ( clientSecret ) ;
362
+ document . body . appendChild ( form ) ;
363
+ form . submit ( ) ;
364
+ }
347
365
loginViaCognito ( ) : void {
348
366
const form = document . createElement ( 'form' ) ;
349
367
form . method = 'POST' ;
@@ -380,7 +398,7 @@ export class AuthService {
380
398
const clientSecret = document . createElement ( 'input' ) ;
381
399
clientSecret . type = 'hidden' ;
382
400
clientSecret . name = 'logout_uri' ;
383
- clientSecret . value = this . appConfig . publicKey ; ;
401
+ clientSecret . value = this . appConfig . publicKey ;
384
402
form . appendChild ( clientSecret ) ;
385
403
document . body . appendChild ( form ) ;
386
404
form . submit ( ) ;
0 commit comments