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

Using springSecurityService.getCurrentUserId() to grab currentUser's primary identifier? #1030

Open
henryc-agr opened this issue Oct 9, 2024 · 1 comment

Comments

@henryc-agr
Copy link

Issue description

Inside SpringSecurityService.groovy there is a getCurrentUserId() method that returns the id property from the principal. I see no reference to this method in the documentation.

Is this method the optimal way to fetch the currentUser's primary identifier of the applications User entity or should we always use the documented springSecurityService.getCurrentUser() and grab the identifier from this User instance?

The getCurrentUserId() has the benefit of not making an additional database call / transaction to fetch the entire user record (for cases where we just need the identifier).

My concern is that the getCurrentUserId() method is not referenced in any official documentation and therefore it may not be supported or included long term?

Thank you,

henryc-agr

@codeconsole
Copy link
Contributor

if all you need is the user id, getCurrentUserId() would be the preferred way.

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

No branches or pull requests

2 participants