Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Changed profile.username to profile.displayName for header username display #1388

Merged

Conversation

Junjiequan
Copy link
Member

Description

This PR adapts to the SciCatProject/scicat-backend-next#1041
In the above backend PR we have changed profile.username to store oidc.sub by default, which in some cases might return string of numbers instead of user's name. So the change of displaying profile.username to profile.displayName on the header section is required.

Tests included/Docs Updated?

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)
  • Docs updated?
  • New packages used/requires npm install?
  • Toggle added for new features?
  • Requires update of SciCat backend API?

Copy link
Contributor

@bpedersen2 bpedersen2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, could get some simplification.

Actually the replace(' ms-ad',...) is probably wrong at all places, as e.g. the oidc. prefix would need the same handling.

Users without a profile should be limited to the system accounts, if I am not mistaken.

@@ -22,7 +22,7 @@ export const selectCurrentUserName = createSelector(
selectCurrentUser,
(profile, user) => {
if (profile) {
return profile.username.replace("ms-ad.", "");
return profile.displayName.replace("ms-ad.", "");
Copy link
Contributor

@bpedersen2 bpedersen2 Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the replace is probably not needed here then. The backend prepends a marker for the auth source to the username, but should not do that for the displayName.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and all user types do implement the user profile (local, oidc, ldap) . jwt auth relies on the other strategies for initial login/account creation, so we proably can rely on the profile being there (or adopt the BE to ensure that),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bpedersen2 hopefully I understood your comment above correctly.
To clarify further: user profile is created for all accounts, no matter which auth strategy they use. It is safe to assume that profile is always present.
I agree with you that the displayName should not be stored in the db with a prefix.
We should display it as it is saved in the database.

@@ -22,7 +22,7 @@ export const selectCurrentUserName = createSelector(
selectCurrentUser,
(profile, user) => {
if (profile) {
return profile.username.replace("ms-ad.", "");
return profile.displayName.replace("ms-ad.", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bpedersen2 hopefully I understood your comment above correctly.
To clarify further: user profile is created for all accounts, no matter which auth strategy they use. It is safe to assume that profile is always present.
I agree with you that the displayName should not be stored in the db with a prefix.
We should display it as it is saved in the database.

nitrosx and others added 7 commits February 19, 2024 12:54
updated e2e docker compose file to use latest scichat-loopback image from github image repo
removed replace instruction in case username has a prefix in it.
We assume that the prefix is an error to be fixed in data with an additional script.The suffix needs to be removed in data.
Restored docker compose
@Junjiequan Junjiequan requested a review from bpedersen2 March 5, 2024 15:15
@Junjiequan Junjiequan merged commit a8632af into master Mar 5, 2024
6 checks passed
@Junjiequan Junjiequan deleted the SWAP-3745-scicat-be-make-oidc-user-validation-process-confi branch March 5, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants