mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-17 23:42:52 +00:00
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.
This commit is contained in:
parent
80715ae5c7
commit
1bf5527eac
15 changed files with 120 additions and 96 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue