diff options
author | yp05327 <576951401@qq.com> | 2023-03-31 23:32:18 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-31 22:32:18 +0800 |
commit | 6e58f8400e911e642957acb6d4b63111d98d3de7 (patch) | |
tree | 83cdabff6d2c0a27c3cf0c65b2707993bc31531f /routers/web/admin/auths.go | |
parent | 7df036f1a50270b15c58084bb4f2502b66d562ae (diff) | |
download | gitea-6e58f8400e911e642957acb6d4b63111d98d3de7.tar.gz gitea-6e58f8400e911e642957acb6d4b63111d98d3de7.zip |
Fix 500 error if there is a name conflict when edit authentication source (#23832)
Diffstat (limited to 'routers/web/admin/auths.go')
-rw-r--r-- | routers/web/admin/auths.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/routers/web/admin/auths.go b/routers/web/admin/auths.go index d2953f753d..6ebd23b7bb 100644 --- a/routers/web/admin/auths.go +++ b/routers/web/admin/auths.go @@ -426,9 +426,11 @@ func EditAuthSourcePost(ctx *context.Context) { source.IsActive = form.IsActive source.IsSyncEnabled = form.IsSyncEnabled source.Cfg = config - // FIXME: if the name conflicts, it will result in 500: Error 1062: Duplicate entry 'aa' for key 'login_source.UQE_login_source_name' if err := auth.UpdateSource(source); err != nil { - if oauth2.IsErrOpenIDConnectInitialize(err) { + if auth.IsErrSourceAlreadyExist(err) { + ctx.Data["Err_Name"] = true + ctx.RenderWithErr(ctx.Tr("admin.auths.login_source_exist", err.(auth.ErrSourceAlreadyExist).Name), tplAuthEdit, form) + } else if oauth2.IsErrOpenIDConnectInitialize(err) { ctx.Flash.Error(err.Error(), true) ctx.Data["Err_DiscoveryURL"] = true ctx.HTML(http.StatusOK, tplAuthEdit) |