From 04a60a41e0f691564c8d27c4d2a922cb03ecde8f Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Fri, 20 Mar 2026 12:02:44 +0800 Subject: [PATCH] Allow default admin user login ragflow user of go server (#13715) ### What problem does this PR solve? 1. Allow admin@ragflow.io login go ragflow server 2. Fix go server start error. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Signed-off-by: Jin Hai --- internal/admin/handler.go | 2 +- internal/handler/user.go | 2 +- internal/server/config.go | 22 +++++++++++----------- internal/service/user.go | 6 +----- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/internal/admin/handler.go b/internal/admin/handler.go index c6d11e4304..7bdf99f633 100644 --- a/internal/admin/handler.go +++ b/internal/admin/handler.go @@ -133,7 +133,7 @@ func (h *Handler) Login(c *gin.Context) { // Use userService.LoginByEmail with adminLogin=true // This allows default admin account to login admin system - user, code, err := h.userService.LoginByEmail(&req, true) + user, code, err := h.userService.LoginByEmail(&req) if err != nil { c.JSON(http.StatusOK, gin.H{ "code": code, diff --git a/internal/handler/user.go b/internal/handler/user.go index 651115115d..645683cc28 100644 --- a/internal/handler/user.go +++ b/internal/handler/user.go @@ -187,7 +187,7 @@ func (h *UserHandler) LoginByEmail(c *gin.Context) { return } - user, code, err := h.userService.LoginByEmail(&req, false) + user, code, err := h.userService.LoginByEmail(&req) if err != nil { c.JSON(http.StatusOK, gin.H{ "code": code, diff --git a/internal/server/config.go b/internal/server/config.go index 1bc2c9847d..deb4ce10cb 100644 --- a/internal/server/config.go +++ b/internal/server/config.go @@ -425,17 +425,17 @@ func FromEnvironments() error { } // Storage - storageType := strings.ToLower(os.Getenv("STORAGE_IMPL")) - switch storageType { - case "minio": - globalConfig.StorageEngine.Type = StorageMinio - case "s3": - globalConfig.StorageEngine.Type = StorageS3 - case "oss": - globalConfig.StorageEngine.Type = StorageOSS - default: - return fmt.Errorf("invalid storage type: %s", storageType) - } + //storageType := strings.ToLower(os.Getenv("STORAGE_IMPL")) + //switch storageType { + //case "minio": + // globalConfig.StorageEngine.Type = StorageMinio + //case "s3": + // globalConfig.StorageEngine.Type = StorageS3 + //case "oss": + // globalConfig.StorageEngine.Type = StorageOSS + //default: + // return fmt.Errorf("invalid storage type: %s", storageType) + //} // Language if globalConfig.Language == "" { diff --git a/internal/service/user.go b/internal/service/user.go index dbdb3db847..a0a263fa71 100644 --- a/internal/service/user.go +++ b/internal/service/user.go @@ -314,11 +314,7 @@ func (s *UserService) Login(req *LoginRequest) (*model.User, common.ErrorCode, e // - CodeAuthenticationError (109): Email not registered or password mismatch // - CodeServerError (500): Password decryption failure // - CodeForbidden (403): Account disabled -func (s *UserService) LoginByEmail(req *EmailLoginRequest, adminLogin bool) (*model.User, common.ErrorCode, error) { - if !adminLogin && req.Email == "admin@ragflow.io" { - return nil, common.CodeAuthenticationError, fmt.Errorf("default admin account cannot be used to login normal services") - } - +func (s *UserService) LoginByEmail(req *EmailLoginRequest) (*model.User, common.ErrorCode, error) { user, err := s.userDAO.GetByEmail(req.Email) if err != nil { return nil, common.CodeAuthenticationError, fmt.Errorf("Email: %s is not registered!", req.Email)