-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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 logging to user management endpoints #2821
Conversation
Closing in favor of #2836, because of too many conflicts. |
// req.user is empty for public routes, so just proceed | ||
// owner can do anything, so proceed as well | ||
if (req.user === undefined || (req.user && (req.user as User).globalRole.name === 'owner')) { | ||
if (!req.user || (isAuthenticatedRequest(req) && req.user.globalRole.name === 'owner')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't !req.user
and isAuthenticatedRequest(req)
doing the same thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly. The type guard specifies not only that req.user
is not undefined
but also that req.user
is of type User
, which allows for role access without the assertion. Without the type guard, in the second half we know that req.user
is not undefined
but not what type it is.
WIP