mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
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:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 == "" {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user