Added Gitea oauth to the admin dashboard and finished the oauth handling

This commit is contained in:
2025-09-15 22:24:12 +03:30
parent a84156f0a0
commit d4044b0eaf
11 changed files with 228 additions and 230 deletions
+13 -4
View File
@@ -11,22 +11,31 @@ import (
type OauthLoginHandler struct {
Jwt auth.JwtTokenGenerator
OauthLoginHandler auth.GiteaOAuth2Handler
OauthLoginHandler *auth.GiteaOAuth2Handler
}
var OauthLoginHandlerInstance *OauthLoginHandler
func InitOauthLoginHandler() {
OauthLoginHandlerInstance = &OauthLoginHandler{
Jwt: *auth.JwtTokenGeneratorInstance,
Jwt: *auth.JwtTokenGeneratorInstance,
OauthLoginHandler: auth.GiteaOauth2HandlerInstance,
}
}
func (_ *OauthLoginHandler) GoToGiteaLogin(c *gin.Context) {
c.Redirect(http.StatusFound, auth.GiteaOauth2HandlerInstance.GetGiteaLoginURL(c.Request.Host))
func (olh *OauthLoginHandler) GoToGiteaLogin(c *gin.Context) {
redirectURL, _ := olh.OauthLoginHandler.GetGiteaLoginURL(c.Request.URL.Scheme + c.Request.Host)
if redirectURL != "" {
c.Redirect(http.StatusFound, redirectURL)
return
}
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to get gitea login url"})
}
func (olh *OauthLoginHandler) LoginWithGitea(c *gin.Context) {
var input dto.GiteaLoginInput
if err := c.ShouldBindJSON(&input); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -13,8 +13,8 @@
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary_large_image" />
<script type="module" crossorigin src="/admin/assets/index-JxecVd-K.js"></script>
<link rel="stylesheet" crossorigin href="/admin/assets/index-DShmOgsI.css">
<script type="module" crossorigin src="/admin/assets/index-D2PXWyfl.js"></script>
<link rel="stylesheet" crossorigin href="/admin/assets/index-BvVLAYUm.css">
</head>
<body>