feat(admin): show and filter users by authentication source - #38900
feat(admin): show and filter users by authentication source#38900Zettat123 wants to merge 4 commits into
Conversation
| ctx.Data["Sources"] = sources | ||
| ctx.Data["SourceNames"] = sourceNames | ||
|
|
||
| sourceIDFilter := optional.ParseInt64(ctx.FormString("source_id")) |
There was a problem hiding this comment.
Why not use FormInt64 like other places.
There was a problem hiding this comment.
FormInt64 returns 0 for a missing, empty or invalid value, so it can't distinguish "no filter" from "filter for local users"(0 is a real value here since user.login_source is 0 for local accounts).
However, this is definitely a point of divergence: in API, source_id = 0 means not filtering users by authentication source (because API doesn't support filtering users by local auth source)
| {{range .Sources}} | ||
| <label class="item"><input type="radio" name="source_id" value="{{.ID}}" {{if eq $selectedSourceID .ID}}checked{{end}}> {{.Name}}</label> | ||
| {{end}} |
There was a problem hiding this comment.
| ctx.Data["Sources"] = sources | ||
| ctx.Data["SourceNames"] = sourceNames | ||
|
|
||
| sourceIDFilter := optional.ParseInt64(ctx.FormString("source_id")) |
There was a problem hiding this comment.
It should be ctx.FormOptionalInt64
| Types: []user_model.UserType{user_model.UserTypeIndividual}, | ||
| LoginName: ctx.FormTrim("login_name"), | ||
| SourceID: ctx.FormInt64("source_id"), | ||
| SourceID: optional.FromNonDefault(ctx.FormInt64("source_id")), |
There was a problem hiding this comment.
It should be ctx.FormOptionalInt64
| </tr> | ||
| {{else}} | ||
| <tr class="no-results-row"><td class="tw-text-center" colspan="9">{{ctx.Locale.Tr "no_results_found"}}</td></tr> | ||
| <tr class="no-results-row"><td class="tw-text-center" colspan="{{Iif $.Sources 10 9}}">{{ctx.Locale.Tr "no_results_found"}}</td></tr> |
There was a problem hiding this comment.
auth source column can always be there, no need to use such fragile {Iif $.Sources 10 9}} trick
Admins running external authentication (LDAP, OAuth2, ...) currently cannot tell from the user list which accounts belong to which source, and cannot narrow the list down to one source.
This adds an "Authentication Source" filter and a matching column to the admin user list.
Localis a selectable value, so accounts not tied to any source can be listed too. Both the filter and the column are hidden on instances with no authentication source configured. Deactivated sources are included, since users stay attached to a source after it is disabled.Screenshots: