aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/admin/users.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-11-03 09:41:00 +0800
committerGitHub <noreply@github.com>2023-11-03 01:41:00 +0000
commit1bf5527eac6b947010c8faf408f6747de2a2384f (patch)
treea78319354a20c1ca68d6ab78268ae9811a7f854c /routers/web/admin/users.go
parent80715ae5c7ca41a8ee2ad7b6459c587cc63195bf (diff)
downloadgitea-1bf5527eac6b947010c8faf408f6747de2a2384f.tar.gz
gitea-1bf5527eac6b947010c8faf408f6747de2a2384f.zip
Refactor Find Sources and fix bug when view a user who belongs to an unactive auth source (#27798)
The steps to reproduce it. First, create a new oauth2 source. Then, a user login with this oauth2 source. Disable the oauth2 source. Visit users -> settings -> security, 500 will be displayed. This is because this page only load active Oauth2 sources but not all Oauth2 sources.
Diffstat (limited to 'routers/web/admin/users.go')
-rw-r--r--routers/web/admin/users.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go
index 91a578fb55..630d739836 100644
--- a/routers/web/admin/users.go
+++ b/routers/web/admin/users.go
@@ -90,7 +90,9 @@ func NewUser(ctx *context.Context) {
ctx.Data["login_type"] = "0-0"
- sources, err := auth.Sources(ctx)
+ sources, err := auth.FindSources(ctx, auth.FindSourcesOptions{
+ IsActive: util.OptionalBoolTrue,
+ })
if err != nil {
ctx.ServerError("auth.Sources", err)
return
@@ -109,7 +111,9 @@ func NewUserPost(ctx *context.Context) {
ctx.Data["DefaultUserVisibilityMode"] = setting.Service.DefaultUserVisibilityMode
ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice()
- sources, err := auth.Sources(ctx)
+ sources, err := auth.FindSources(ctx, auth.FindSourcesOptions{
+ IsActive: util.OptionalBoolTrue,
+ })
if err != nil {
ctx.ServerError("auth.Sources", err)
return
@@ -230,7 +234,7 @@ func prepareUserInfo(ctx *context.Context) *user_model.User {
ctx.Data["LoginSource"] = &auth.Source{}
}
- sources, err := auth.Sources(ctx)
+ sources, err := auth.FindSources(ctx, auth.FindSourcesOptions{})
if err != nil {
ctx.ServerError("auth.Sources", err)
return nil