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

feat: add is_current and profile_link methods #2924

Merged
merged 1 commit into from Feb 27, 2024

Conversation

Levdbas
Copy link
Member

@Levdbas Levdbas commented Feb 18, 2024

Related:

Issue

As discussed in #2676, we could add a User::profile_link() method that get’s the link the profile admin page if a user is logged in. This is more clear than User::edit_link(), where you might assume that you get URL to edit other users.

Solution

  • Add is_current method as an api method that checks if the current User object id is the same as the current (logged in) user.
  • Use that method in the new profile_link method to check whether to return the profile url.

Impact

A more clear method to get the profile url for the current user and as a bonus, a way to check if we are working with the current logged in user, which comes in handy for creating extensive front-end user profiles for example.

Usage Changes

no.

Considerations

Maybe we want to cache the result of the is_current method?

Testing

Yes, tests included for both methods.

@Levdbas Levdbas linked an issue Feb 18, 2024 that may be closed by this pull request
2 tasks
@Levdbas Levdbas merged commit b048da8 into 2.x Feb 27, 2024
26 of 28 checks passed
@gchtr gchtr deleted the 2682-add-userprofile_link-method branch February 27, 2024 07:24
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.

Add User::profile_link() method
2 participants