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

Add First and Last name to the user identity object #3832

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

rdimitrov
Copy link
Member

Summary

The following PR adds First and Last name to the user identity object and to the ListRoleAssignments response.

Fixes #3831

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@rdimitrov rdimitrov requested a review from a team as a code owner July 10, 2024 12:48
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
@coveralls
Copy link

coveralls commented Jul 10, 2024

Coverage Status

coverage: 52.141% (+0.01%) from 52.128%
when pulling e4b684a on add-first-last-name
into 9fbf426 on main.

Comment on lines +160 to +172
ret := &auth.Identity{
UserID: *user.Id,
HumanName: *user.Username,
Provider: k,
}
// If the user has a first and last name, return them too
if user.FirstName != nil {
ret.FirstName = *user.FirstName
}
if user.LastName != nil {
ret.LastName = *user.LastName
}
return ret
Copy link
Member

Choose a reason for hiding this comment

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

I think you can take advantage of proto3's empty-field behavior and simplify:

Suggested change
ret := &auth.Identity{
UserID: *user.Id,
HumanName: *user.Username,
Provider: k,
}
// If the user has a first and last name, return them too
if user.FirstName != nil {
ret.FirstName = *user.FirstName
}
if user.LastName != nil {
ret.LastName = *user.LastName
}
return ret
ret := &auth.Identity{
UserID: *user.Id,
HumanName: *user.Username,
Provider: k,
FirstName: *user.FirstName,
LastName: *user.LastName,
}
return ret

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I did try it like that but for users where this was missing, it was failing because of the nil reference.

@rdimitrov rdimitrov merged commit 3931da3 into main Jul 10, 2024
22 checks passed
@rdimitrov rdimitrov deleted the add-first-last-name branch July 10, 2024 13:34
dmjb pushed a commit that referenced this pull request Jul 12, 2024
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
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.

Extend the user identity object to include first and last name
3 participants