diff --git a/internal/web/auth.go b/internal/web/auth.go index 3e54f33..1e21a6a 100644 --- a/internal/web/auth.go +++ b/internal/web/auth.go @@ -163,7 +163,7 @@ func oauthCallback(ctx echo.Context) error { if err = userDB.Create(); err != nil { if models.IsUniqueConstraintViolation(err) { - addFlash(ctx, "Username "+user.NickName+" already exists in opengist", "error") + addFlash(ctx, "Username "+user.NickName+" already exists in Opengist", "error") return redirect(ctx, "/login") } diff --git a/internal/web/run.go b/internal/web/run.go index c014a8a..efaf095 100644 --- a/internal/web/run.go +++ b/internal/web/run.go @@ -249,6 +249,9 @@ func dataInit(next echo.HandlerFunc) echo.HandlerFunc { } setData(ctx, "signupDisabled", disableSignup == "1") + setData(ctx, "githubOauth", config.C.GithubClientKey != "" && config.C.GithubSecret != "") + setData(ctx, "giteaOauth", config.C.GiteaClientKey != "" && config.C.GiteaSecret != "") + return next(ctx) } } diff --git a/templates/pages/auth_form.html b/templates/pages/auth_form.html index 9d05793..0abae36 100644 --- a/templates/pages/auth_form.html +++ b/templates/pages/auth_form.html @@ -48,6 +48,25 @@ {{ end }} {{ .csrfHtml }} + +
+ +
+
+
+ {{ if .githubOauth }} + + Continue with GitHub account + + {{ end }} + {{ if .giteaOauth }} + + Continue with Gitea account + + {{ end }} +
diff --git a/templates/pages/settings.html b/templates/pages/settings.html index 9809029..ca6c824 100644 --- a/templates/pages/settings.html +++ b/templates/pages/settings.html @@ -7,7 +7,7 @@
-
+

@@ -27,34 +27,42 @@

+ {{ if or .githubOauth .giteaOauth }}

Link accounts

- {{ if .userLogged.GithubID }} - - Unlink GitHub account - - {{ else }} - - Link GitHub account - - {{ end }} - {{ if .userLogged.GiteaID }} - - Unlink Gitea account - - {{ else }} - - Link Gitea account - - {{ end }} + {{ if .githubOauth }} + {{ if .userLogged.GithubID }} + + Unlink GitHub account + + {{ else }} + + Link GitHub account + + {{ end }} + {{ end }} + + {{ if .giteaOauth }} + {{ if .userLogged.GiteaID }} + + Unlink Gitea account + + {{ else }} + + Link Gitea account + + {{ end }} + {{ end }} +
+ {{ end }}

@@ -68,7 +76,7 @@

-
+