-
Notifications
You must be signed in to change notification settings - Fork 45
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
Added Filter by Role to user search #1278
base: dev
Are you sure you want to change the base?
Conversation
Your Testserver will be ready at https://1278.test.live.mm.rbg.tum.de in a few minutes. Logins
|
There's a small problem: after filtering, the user's email doesn't seem to be displayed |
Filtering locally results in no show of potential results. Simplest case of this is filtering for students without query string. Change the API instead. |
I cannot reproduce this problem in Mozilla Firefox for Ubuntu 132.0.2 (64-Bit) or Google Chrome Version 130.0.6723.58 (Official Build) (64-bit). |
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.
Looks great, just added two remarks
Co-authored-by: Joscha Henningsen <[email protected]>
api/users.go
Outdated
@@ -125,16 +126,31 @@ func (r usersRoutes) updateUser(c *gin.Context) { | |||
|
|||
func (r usersRoutes) prepareUserSearch(c *gin.Context) (users []model.User, err error) { | |||
q := c.Query("q") | |||
reg, _ := regexp.Compile("[^a-zA-Z0-9 ]+") | |||
rQ := c.Query("r") | |||
reg := regexp.MustCompile("[^a-zA-Z0-9 ]+") | |||
q = reg.ReplaceAllString(q, "") |
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.
all of these variable names are hard to understand without context. Also why are we only enforcing the regex on one of the two paramters? Does rQ not need to be checked for validity?
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.
Edited the PR, PTAL if you think thats better (otherwise revert my commit please).
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.
Also why are we only enforcing the regex on one of the two paramters? Does rQ not need to be checked for validity?
Probably hard to immediately understand and therefore bad code, but it's checked before it's used:
Lines 143 to 144 in 6d0c3cc
role, err := strconv.ParseUint(roleQuery, 10, 64) | |
if err != nil { |
Motivation and Context
You can now filter users by their role, improves administration and overview over admins.
Steps for Testing
Prerequisites:
Screenshots