-
Notifications
You must be signed in to change notification settings - Fork 19
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
🕹 Manage root users #146
🕹 Manage root users #146
Conversation
@@ -175,6 +186,13 @@ export class DocumentsController { | |||
) | |||
: [], | |||
}; | |||
|
|||
if(id == "root" && companyUserRole < 1) { |
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.
What does 1
mean?
(Magic constant spotted).
I recommend to extract this as a global variable and give it a name.
/* useEffect(() => { | ||
props.onChangePassword(usePassword ? password : ''); | ||
}, [usePassword, password]); */ |
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.
Remove commented code?
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.
My 2 cents...
@@ -187,7 +189,7 @@ export class DocumentsController { | |||
: [], | |||
}; | |||
|
|||
if(id == "root" && companyUserRole < 1) { | |||
if (id == "root" && companyUserRole < 1) { |
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.
What is the meaning of 1
here?
That's the magic constant syndrom. I would recommand to:
-
- Strong type. It looks like some kind of permissions is encoded as an
int
. This could be made explicit with a type, that could furthermore encapsulate and centralize right checking logic, that then could (must?) be unit tested?
- Strong type. It looks like some kind of permissions is encoded as an
-
- Extract constants to give them a name. Favor
enum
s if supported in typescript.
- Extract constants to give them a name. Favor
{ id: update.company_id }, | ||
{ id: update.user_id }, | ||
); | ||
if (companyUser) { |
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.
What happens if the guy is not a company user?
We likely should return an HTTP error for this, no? 406
not acceptable ?
Coverage Report
Click to view remaining coverage report
|
@@ -189,7 +189,7 @@ export class DocumentsController { | |||
: [], | |||
}; | |||
|
|||
if (id == "root" && companyUserRole < 1) { | |||
if (id == "root" && companyUserRole == 1) { |
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.
Can we create constants for each value user role?
Or even better use an enum: https://www.typescriptlang.org/docs/handbook/enums.html ?
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.
The snippet above is outdated.
No description provided.