modernize the codebase
Run the modernize linter across the codebase. Change generated by running: ``` go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... ``` Ref: https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
This commit is contained in:
@@ -28,7 +28,7 @@ func NewAdminDashboardHandler(
|
||||
postService: postService,
|
||||
jwt: jwt,
|
||||
cfg: cfg,
|
||||
imgKit: imgKit,
|
||||
imgKit: imgKit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ func (adh *AdminDashboardHandler) RejectMedia(c *gin.Context) {
|
||||
func (adh *AdminDashboardHandler) GetMedia(c *gin.Context) {
|
||||
media := adh.postService.GetMedia()
|
||||
// TODO: Fix this - we need to inject ImgKitHelper
|
||||
media.PreviewUrl = adh.imgKit.GetPreviewUrl(media.RemoteUrl)
|
||||
media.RemoteUrl = adh.imgKit.GetRemoteUrl(media.RemoteUrl)
|
||||
media.PreviewUrl = adh.imgKit.GetPreviewUrl(media.RemoteUrl)
|
||||
media.RemoteUrl = adh.imgKit.GetRemoteUrl(media.RemoteUrl)
|
||||
c.JSON(http.StatusOK, media)
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func (adh *AdminDashboardHandler) Login(c *gin.Context) {
|
||||
}
|
||||
|
||||
if input.Password == adh.cfg.AdminPassword { // Its more than enough for this project
|
||||
token, err := adh.jwt.GenerateToken(map[string]interface{}{"role": "admin"})
|
||||
token, err := adh.jwt.GenerateToken(map[string]any{"role": "admin"})
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Token generation failed"})
|
||||
return
|
||||
@@ -97,4 +97,4 @@ func (adh *AdminDashboardHandler) Login(c *gin.Context) {
|
||||
// Expose the JWT middleware for use in routes
|
||||
func (adh *AdminDashboardHandler) JWTMiddleware() gin.HandlerFunc {
|
||||
return adh.jwt.GinMiddleware()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ import (
|
||||
)
|
||||
|
||||
type OauthLoginHandler struct {
|
||||
jwt *auth.JwtTokenGenerator
|
||||
jwt *auth.JwtTokenGenerator
|
||||
oauthHandler *auth.GiteaOAuth2Handler
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
func NewOauthLoginHandler(
|
||||
@@ -55,7 +55,7 @@ func (olh *OauthLoginHandler) LoginWithGitea(c *gin.Context) {
|
||||
// Check if the user's email is in the allowed list
|
||||
for _, email := range olh.cfg.GiteaOauthAllowedEmails {
|
||||
if email == userEmail {
|
||||
token, err := olh.jwt.GenerateToken(map[string]interface{}{"role": "admin"})
|
||||
token, err := olh.jwt.GenerateToken(map[string]any{"role": "admin"})
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "Token generation failed"})
|
||||
return
|
||||
@@ -70,4 +70,4 @@ func (olh *OauthLoginHandler) LoginWithGitea(c *gin.Context) {
|
||||
c.JSON(401, gin.H{
|
||||
"error": "oauth login failed or your email does not have access",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user