diff --git a/cmd/web/docs/docs.go b/cmd/web/docs/docs.go index 58266af..71c4e22 100644 --- a/cmd/web/docs/docs.go +++ b/cmd/web/docs/docs.go @@ -7001,11 +7001,6 @@ const docTemplate = `{ "user.CreateUserForm": { "type": "object", "properties": { - "company_id": { - "description": "Optional company UUID", - "type": "string", - "example": "123e4567-e89b-12d3-a456-426614174000" - }, "department": { "description": "Optional department name", "type": "string", diff --git a/cmd/web/docs/swagger.json b/cmd/web/docs/swagger.json index 48876c5..93d5e5d 100644 --- a/cmd/web/docs/swagger.json +++ b/cmd/web/docs/swagger.json @@ -6995,11 +6995,6 @@ "user.CreateUserForm": { "type": "object", "properties": { - "company_id": { - "description": "Optional company UUID", - "type": "string", - "example": "123e4567-e89b-12d3-a456-426614174000" - }, "department": { "description": "Optional department name", "type": "string", diff --git a/cmd/web/docs/swagger.yaml b/cmd/web/docs/swagger.yaml index 285d115..13fed6e 100644 --- a/cmd/web/docs/swagger.yaml +++ b/cmd/web/docs/swagger.yaml @@ -1308,10 +1308,6 @@ definitions: type: object user.CreateUserForm: properties: - company_id: - description: Optional company UUID - example: 123e4567-e89b-12d3-a456-426614174000 - type: string department: description: Optional department name example: Information Technology diff --git a/internal/user/entity.go b/internal/user/entity.go index 90e30cc..8c66699 100644 --- a/internal/user/entity.go +++ b/internal/user/entity.go @@ -34,7 +34,6 @@ type User struct { Password string `bson:"password" json:"-"` // Never serialize password Role UserRole `bson:"role" json:"role"` Status UserStatus `bson:"status" json:"status"` - CompanyID *string `bson:"company_id,omitempty" json:"company_id,omitempty"` Department *string `bson:"department,omitempty" json:"department,omitempty"` Position *string `bson:"position,omitempty" json:"position,omitempty"` Phone *string `bson:"phone,omitempty" json:"phone,omitempty"` diff --git a/internal/user/form.go b/internal/user/form.go index 1e7972a..5b43e18 100644 --- a/internal/user/form.go +++ b/internal/user/form.go @@ -4,16 +4,15 @@ package user // CreateUserForm represents the data required to create a new user account type CreateUserForm struct { - FullName string `json:"full_name" valid:"required,length(2|100)" example:"John Smith"` // Full name of the user - Username string `json:"username" valid:"required,alphanum,length(3|30)" example:"johnsmith"` // Unique username (alphanumeric only) - Email string `json:"email" valid:"required,email" example:"john.smith@company.com"` // Valid email address - Password string `json:"password" valid:"required,length(8|128)" example:"SecurePass123!"` // Password (minimum 8 characters) - Role string `json:"role" valid:"required,in(admin|manager|operator|viewer)" example:"manager"` // User role (admin, manager, operator, viewer) - CompanyID *string `json:"company_id,omitempty" valid:"optional,uuid" example:"123e4567-e89b-12d3-a456-426614174000"` // Optional company UUID - Department *string `json:"department,omitempty" valid:"optional,length(2|100)" example:"Information Technology"` // Optional department name - Position *string `json:"position,omitempty" valid:"optional,length(2|100)" example:"Senior Developer"` // Optional job position - Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)" example:"+1234567890"` // Optional phone number - ProfileImage *string `json:"profile_image,omitempty" valid:"optional,url" example:"https://example.com/avatar.jpg"` // Optional profile image URL + FullName string `json:"full_name" valid:"required,length(2|100)" example:"John Smith"` // Full name of the user + Username string `json:"username" valid:"required,alphanum,length(3|30)" example:"johnsmith"` // Unique username (alphanumeric only) + Email string `json:"email" valid:"required,email" example:"john.smith@company.com"` // Valid email address + Password string `json:"password" valid:"required,length(8|128)" example:"SecurePass123!"` // Password (minimum 8 characters) + Role string `json:"role" valid:"required,in(admin|manager|operator|viewer)" example:"manager"` // User role (admin, manager, operator, viewer) + Department *string `json:"department,omitempty" valid:"optional,length(2|100)" example:"Information Technology"` // Optional department name + Position *string `json:"position,omitempty" valid:"optional,length(2|100)" example:"Senior Developer"` // Optional job position + Phone *string `json:"phone,omitempty" valid:"optional,length(10|20)" example:"+1234567890"` // Optional phone number + ProfileImage *string `json:"profile_image,omitempty" valid:"optional,url" example:"https://example.com/avatar.jpg"` // Optional profile image URL } // UpdateUserForm represents the data for updating an existing user account @@ -128,7 +127,6 @@ func (u *User) ToResponse() *UserResponse { Email: u.Email, Role: string(u.Role), Status: string(u.Status), - CompanyID: u.CompanyID, Department: u.Department, Position: u.Position, Phone: u.Phone, diff --git a/internal/user/service.go b/internal/user/service.go index 3ec28fb..1e1a2a5 100644 --- a/internal/user/service.go +++ b/internal/user/service.go @@ -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 }