Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
fix: the user info in navigation return empty string after refreshing…
Browse files Browse the repository at this point in the history
… the token
  • Loading branch information
MitanOmar committed Apr 16, 2024
1 parent 4c46213 commit 59ea9c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions app/components/sy-topnav/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,23 @@ export default class SyTopnav extends Component {
get navMobile() {
return this.media.isMo || this.media.isXs || this.media.isSm;
}

/**
* TODO:
* i don't know if it's an issue in `ember-simple-auth` or `ember-simple-auth-oidc`
* or it's maybe wrong configration from Timed frontend side,
* BUT after refreshing the token, the session service is not encapsulating the reslts from keycloak
* inside ember data model, so i add this small.
*
* if the issue is fixed, change everything in app/abilities/report.js that belongs to `this.user?.id`
*/
get fullName() {
const fullName = this.session.data.user?.fullName;
if (fullName) return fullName;

if (!this.session.data.user?.attributes) return "";

const userAttributes = this.session.data.user.attributes;
return `${userAttributes["first-name"]} ${userAttributes["last-name"]}`;

Check warning on line 32 in app/components/sy-topnav/component.js

View check run for this annotation

Codecov / codecov/patch

app/components/sy-topnav/component.js#L31-L32

Added lines #L31 - L32 were not covered by tests
}
}
2 changes: 1 addition & 1 deletion app/components/sy-topnav/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<li class="nav-top-list-item">
<LinkTo @route="users.edit" @model={{this.session.data.user.id}}>
<FaIcon @icon="user" />
{{this.session.data.user.fullName}}
{{this.fullName}}
</LinkTo>
</li>
<li class="nav-top-list-item">
Expand Down

0 comments on commit 59ea9c5

Please sign in to comment.