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 <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-03-20 12:02:44 +08:00
committed by GitHub
parent 13d0df1562
commit 04a60a41e0
4 changed files with 14 additions and 18 deletions

View File

@@ -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,

View File

@@ -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,

View File

@@ -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 == "" {

View File

@@ -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)