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 logging to user management endpoints #2821

Closed
wants to merge 28 commits into from

Conversation

ivov
Copy link
Contributor

@ivov ivov commented Feb 14, 2022

WIP

@ivov ivov added feature Large self-contained feature n8n team Authored by the n8n team labels Feb 14, 2022
@ivov
Copy link
Contributor Author

ivov commented Feb 17, 2022

Closing in favor of #2836, because of too many conflicts.

@ivov ivov closed this Feb 17, 2022
// 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')) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Large self-contained feature n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants