Comments (4)
Hi @czeckd, how are you?
First of all, sorry for the lack of response. Was travelling the past two weeks and didn't have time to watch the issues.
So, about your issue, what about using the user profile? The keycloak-js give us a function to get the user details. Currently the KeycloakProfile has the following attributes:
interface KeycloakProfile {
id?: string;
username?: string;
email?: string;
firstName?: string;
lastName?: string;
enabled?: boolean;
emailVerified?: boolean;
totp?: boolean;
createdTimestamp?: number;
}
Just included in the header of the example keycloak-heroes at the user area, the name and email from the user. Take a look at the app.component.html and app.component.ts.
- app.component.html
<clr-dropdown-menu *clrIfOpen clrPosition="bottom-right">
<div class="userDetails" *ngIf="userDetails">
<h2>{{userDetails.firstName}}</h2>
<p>
{{userDetails.email}}
</p>
</div>
<a href="#" clrDropdownItem>Log out</a>
</clr-dropdown-menu>
- app.component.ts
import { Component, OnInit } from '@angular/core';
import { KeycloakProfile } from 'keycloak-js';
import { KeycloakService } from 'keycloak-angular';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
userDetails: KeycloakProfile;
constructor(private keycloakService: KeycloakService) {}
async ngOnInit() {
this.userDetails = await this.keycloakService.loadUserProfile();
}
}
Let me know if this helps you, otherwise lets talk and think about solutions.
Thanks!
from keycloak-angular.
This will work perfectly! Thank you so much!
from keycloak-angular.
Worked for me too.!! Thanks a lot
from keycloak-angular.
I've noticed that loadUserProfile()
generates a HTTP request (url: `../account).
So if you are obsessed in reducing HTTP Requests, I suggest to use this method only if you can't find the proper information in the tokenParsed
property.
from keycloak-angular.
Related Issues (20)
- Login method locale is not changing the user locale when the user logs in
- angular crashes with check-sso
- Support KC 24.x.x HOT 6
- Catch sign out event or redirect to ssop event
- keycloak-angular - next version improvements HOT 1
- Bug in package.json version 15.2.0 HOT 3
- Keycloak setup for Single SPA angular Project
- HttpClient Interceptor not working HOT 2
- Configure updateToken minValidity in HTTP Interceptor
- Standalone bootstrap: withEnabledBlockingInitialNavigation() causes isLoggedIn() to return false in AuthGuard HOT 2
- Add setup instructions for standalone bootstrap
- Logout the user if he is idle
- Support Angular v18 HOT 2
- Token refresh fails with 400 invalid_grant Token is not active HOT 2
- If Keycloak Auth Domain is down, then Angular 16 keycloak will receive white-page and fail compilation at AppModule level
- Refresh Token is unused HOT 2
- ERROR Error: An error happened during access validation. Details:TypeError: Cannot read properties of undefined (reading 'resourceAccess') HOT 3
- Support Keycloak 25.x.x HOT 1
- Subscription to keycloak Events$ outside Keycloak initialization function do not work
- User logs out after page refresh HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keycloak-angular.