Remove company_id field from user-related forms and documentation

- Deleted the company_id field from CreateUserForm, User entity, and related API documentation in Swagger and YAML files to streamline user creation process.
- Updated the CreateUser service method to reflect the removal of company_id, ensuring consistency across the user management functionality.
This commit is contained in:
n.nakhostin
2025-08-16 10:52:45 +03:30
parent 0a23ff985a
commit 05165c6587
6 changed files with 10 additions and 44 deletions
+1 -18
View File
@@ -73,12 +73,6 @@ func (s *userService) CreateUser(ctx context.Context, form *CreateUserForm, crea
return nil, errors.New("failed to process password")
}
// Parse optional fields
var companyID *string
if form.CompanyID != nil {
companyID = form.CompanyID
}
// Validate role
role := UserRole(form.Role)
if !s.validator.IsValidRole(role) {
@@ -93,7 +87,6 @@ func (s *userService) CreateUser(ctx context.Context, form *CreateUserForm, crea
Password: string(hashedPassword),
Role: role,
Status: UserStatusActive,
CompanyID: companyID,
Department: form.Department,
Position: form.Position,
Phone: form.Phone,
@@ -168,17 +161,11 @@ func (s *userService) Login(ctx context.Context, form *LoginForm) (*AuthResponse
})
}
// Generate JWT tokens using authorization service
companyID := ""
if user.CompanyID != nil {
companyID = *user.CompanyID
}
tokenPair, err := s.authService.GenerateTokenPair(
user.ID.Hex(),
user.Email,
string(user.Role),
companyID,
"",
)
if err != nil {
s.logger.Error("Failed to generate JWT tokens", map[string]interface{}{
@@ -443,10 +430,6 @@ func (s *userService) UpdateUser(ctx context.Context, id string, form *UpdateUse
user.Role = role
}
if form.CompanyID != nil {
user.CompanyID = form.CompanyID
}
if form.Department != nil {
user.Department = form.Department
}