Added Gitea oauth to the admin dashboard and finished the oauth handling
This commit is contained in:
@@ -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
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user