gohorsejobs/backend/internal/dto/auth.go
Tiago Yamamoto 73967ca52b fix(users): allow superadmin to list all users without tenant restriction
- Modified ListUsers handler to check for admin/superadmin role
- Superadmins can now list all users across tenants
- Added ListUsers method to AdminService
- Added Status field to dto.User

Fixes 403 error when superadmin tries to access /api/v1/users
2025-12-26 00:51:54 -03:00

59 lines
1.9 KiB
Go
Executable file

package dto
import (
"time"
)
// LoginRequest represents the login request payload
type LoginRequest struct {
Identifier string `json:"identifier" validate:"required,min=3"`
Password string `json:"password" validate:"required,min=8"`
}
// LoginResponse represents the login response
type LoginResponse struct {
Token string `json:"token"`
User UserInfo `json:"user"`
Companies []CompanyInfo `json:"companies,omitempty"`
ActiveCompanyID *string `json:"activeCompanyId,omitempty"`
}
// UserInfo represents basic user information in responses
type UserInfo struct {
ID string `json:"id"`
Identifier string `json:"identifier"`
Role string `json:"role"`
FullName string `json:"fullName"`
Language string `json:"language"`
}
// CompanyInfo represents basic company information
type CompanyInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Role string `json:"role"` // Role in this company (admin or recruiter)
}
// RegisterRequest represents user registration
type RegisterRequest struct {
Identifier string `json:"identifier" validate:"required,min=3,max=50"`
Password string `json:"password" validate:"required,min=8"`
FullName string `json:"fullName" validate:"required"`
Phone *string `json:"phone,omitempty"`
WhatsApp *string `json:"whatsapp,omitempty"`
LineID *string `json:"lineId,omitempty"`
Instagram *string `json:"instagram,omitempty"`
Language string `json:"language" validate:"required,oneof=pt en es ja"`
Role string `json:"role" validate:"required,oneof=candidate recruiter admin"`
}
// User represents a generic user profile
type User struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Role string `json:"role"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
CompanyID *string `json:"companyId,omitempty"`
}