summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorDaniil Pankratov <mobigod0@gmail.com>2020-12-24 22:47:17 +0300
committerGitHub <noreply@github.com>2020-12-24 19:47:17 +0000
commit5a94db37ed16b253bf6e43ae6337f3a3c21f6d70 (patch)
tree0f4f27450e423eae290a801a325bbd42c17d887c /routers/user
parentbdeccc36886d6df4f2a8fce9e5f71e866e9902fc (diff)
downloadgitea-5a94db37ed16b253bf6e43ae6337f3a3c21f6d70.tar.gz
gitea-5a94db37ed16b253bf6e43ae6337f3a3c21f6d70.zip
Fix creating OAuth2 auth source from CLI (#14116)
Fix creation OAuth2 auth source from CLI. Fix #8356 Co-authored-by: Daniil Pankratov <daniil.pankratov@t-systems.com>
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/auth.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go
index acd88b364c..540a0d2f1a 100644
--- a/routers/user/auth.go
+++ b/routers/user/auth.go
@@ -570,8 +570,17 @@ func SignInOAuth(ctx *context.Context) {
return
}
- err = oauth2.Auth(loginSource.Name, ctx.Req.Request, ctx.Resp)
- if err != nil {
+ if err = oauth2.Auth(loginSource.Name, ctx.Req.Request, ctx.Resp); err != nil {
+ if strings.Contains(err.Error(), "no provider for ") {
+ if err = models.ResetOAuth2(); err != nil {
+ ctx.ServerError("SignIn", err)
+ return
+ }
+ if err = oauth2.Auth(loginSource.Name, ctx.Req.Request, ctx.Resp); err != nil {
+ ctx.ServerError("SignIn", err)
+ }
+ return
+ }
ctx.ServerError("SignIn", err)
}
// redirect is done in oauth2.Auth