Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
angular-oidc-authorization-sample
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Helmut Hutzler
angular-oidc-authorization-sample
Commits
e2b88ee0
Commit
e2b88ee0
authored
2 years ago
by
Helmut Hutzler
Browse files
Options
Downloads
Patches
Plain Diff
Improving display of userdata observable
parent
8ffa195c
No related branches found
No related tags found
No related merge requests found
Pipeline
#9413
passed
2 years ago
Stage: build-production
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/home/home.component.html
+34
-1
34 additions, 1 deletion
src/app/home/home.component.html
src/app/home/home.component.ts
+26
-12
26 additions, 12 deletions
src/app/home/home.component.ts
with
60 additions
and
13 deletions
src/app/home/home.component.html
+
34
−
1
View file @
e2b88ee0
<h3>
Welcome to home Route - shows data from keycloak userData$ observable
</h3>
<h3>
<mat-icon>
home
</mat-icon>
Welcome to home Route - shows data from keycloak userData$ observable
</h3>
<div>
<div>
<hr>
<hr>
...
@@ -6,6 +6,39 @@
...
@@ -6,6 +6,39 @@
<pre>
Username: {{ username }}
</pre>
<pre>
Username: {{ username }}
</pre>
<pre>
OIDC configid: {{ configId }}
</pre>
<pre>
OIDC configid: {{ configId }}
</pre>
<pre>
Default Roles: {{ defaultRoles }}
</pre>
<pre>
Default Roles: {{ defaultRoles }}
</pre>
<ng-template
[ngIf]=
"owner_of_admin_role"
[ngIfElse]=
"not_owner_of_admin_role"
>
<div>
<p>
Owner of Admin role:
<mat-icon>
check
</mat-icon></p>
</div>
</ng-template>
<ng-template
#not_owner_of_admin_role
>
<div>
<p>
Owner of Admin role :
<mat-icon>
clear
</mat-icon></p>
</div>
</ng-template>
<ng-template
[ngIf]=
"owner_of_agent_role"
[ngIfElse]=
"not_owner_of_agent_role"
>
<div>
<p>
Owner of Agent role :
<mat-icon>
check
</mat-icon></p>
</div>
</ng-template>
<ng-template
#not_owner_of_agent_role
>
<div>
<p>
Owner of Agent role :
<mat-icon>
clear
</mat-icon></p>
</div>
</ng-template>
<ng-template
[ngIf]=
"owner_of_admin_role"
[ngIfElse]=
"not_owner_of_superadmin_role"
>
<div>
<p>
Owner of Superadmin role:
<mat-icon>
check
</mat-icon></p>
</div>
</ng-template>
<ng-template
#not_owner_of_superadmin_role
>
<div>
<p>
Owner of Superadmin role :
<mat-icon>
clear
</mat-icon></p>
</div>
</ng-template>
<hr>
<hr>
<h5>
JSON Data from userData$ Observable
</h5>
<h5>
JSON Data from userData$ Observable
</h5>
...
...
This diff is collapsed.
Click to expand it.
src/app/home/home.component.ts
+
26
−
12
View file @
e2b88ee0
...
@@ -32,6 +32,9 @@ export class HomeComponent implements OnInit, OnDestroy {
...
@@ -32,6 +32,9 @@ export class HomeComponent implements OnInit, OnDestroy {
//let account : Account = {}
//let account : Account = {}
//const waldo: Foo = {...}
//const waldo: Foo = {...}
accounts
:
any
[]
;
accounts
:
any
[]
;
owner_of_admin_role
=
false
;
owner_of_superadmin_role
=
false
;
owner_of_agent_role
=
false
;
constructor
(
public
oidcSecurityService
:
OidcSecurityService
,
constructor
(
public
oidcSecurityService
:
OidcSecurityService
,
private
http
:
HttpClient
,
private
http
:
HttpClient
,
...
@@ -59,22 +62,33 @@ export class HomeComponent implements OnInit, OnDestroy {
...
@@ -59,22 +62,33 @@ export class HomeComponent implements OnInit, OnDestroy {
console
.
log
(
'
userDataResult::
'
);
console
.
log
(
'
userDataResult::
'
);
/* Check for null and undefined or main object and nested userData objects
/* Check for null and undefined or main object and nested userData objects
* There are two different userdata objects holding the same data.
* There are two different userdata objects holding the same data.
* Not sure why we have duplicate data here
* This allows to switch between multiple config files.
* - userDataResult.userData -> Singe Object
* - userDataResult.allUserData[0].userData -> Array of Objects
*
* During Logoff this the userData Objects are set to null !
* During Logoff this the userData Objects are set to null !
* If have multiple config files detail can be found looking at allUserData[] array
* userDataResult.allUserData[0].userData.email
*/
*/
if
(
userDataResult
!=
null
)
{
if
(
userDataResult
!=
null
)
{
if
(
userDataResult
.
allUserData
[
0
].
userData
!=
null
)
{
if
(
userDataResult
.
userData
!=
null
)
{
// ...
// ...
this
.
configId
=
userDataResult
.
allUserData
[
0
].
configId
;
this
.
username
=
userDataResult
.
userData
.
preferred_username
;
this
.
username
=
userDataResult
.
allUserData
[
0
].
userData
.
preferred_username
;
this
.
accountService
.
setPreferredUsername
(
this
.
username
);
this
.
accountService
.
setPreferredUsername
(
this
.
username
);
this
.
email
=
userDataResult
.
allUserData
[
0
].
userData
.
email
;
this
.
email
=
userDataResult
.
userData
.
email
;
this
.
defaultRoles
=
userDataResult
.
allUserData
[
0
].
userData
.
default_roles
;
this
.
defaultRoles
=
userDataResult
.
userData
.
default_roles
;
console
.
log
(
'
userDataResult.allUserData[0].configId :
'
,
this
.
configId
);
console
.
log
(
'
userData.configId :
'
,
this
.
configId
);
console
.
log
(
'
userDataResult.allUserData[0].userData.email :
'
,
this
.
email
);
console
.
log
(
'
userData.userData.email :
'
,
this
.
email
);
console
.
log
(
'
userData.default_roles :
'
,
this
.
defaultRoles
);
if
(
this
.
defaultRoles
.
includes
(
'
rbac_admin_role
'
)
)
{
this
.
owner_of_admin_role
=
true
;
console
.
log
(
'
---
'
+
this
.
username
+
'
is owner of the Admin Role !
'
);
}
if
(
this
.
defaultRoles
.
includes
(
'
rbac_superadmin_role
'
)
)
{
this
.
owner_of_superadmin_role
=
true
;
console
.
log
(
'
---
'
+
this
.
username
+
'
is owner of the Superadmin Role !
'
);
}
if
(
this
.
defaultRoles
.
includes
(
'
rbac_agent_role
'
)
)
{
this
.
owner_of_agent_role
=
true
;
console
.
log
(
'
---
'
+
this
.
username
+
'
is owner of the Agent Role !
'
);
}
}
}
// this.getAccounts();
// this.getAccounts();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment