Documentation
¶
Index ¶
- type AuthResponse
- type Config
- type Service
- func (s *Service) CheckCredentials(ctx context.Context, email, password string) (*user.User, error)
- func (s *Service) CreateSessionForUser(ctx context.Context, u *user.User, remember bool, ip, ua string) (*responses.AuthResponse, error)
- func (s *Service) GetSession(ctx context.Context, token string) (*responses.AuthResponse, error)
- func (s *Service) SignIn(ctx context.Context, req *SignInRequest) (*responses.AuthResponse, error)
- func (s *Service) SignOut(ctx context.Context, req *SignOutRequest) error
- func (s *Service) SignUp(ctx context.Context, req *SignUpRequest) (*responses.AuthResponse, error)
- func (s *Service) UpdateUser(ctx context.Context, userID xid.ID, req *user.UpdateUserRequest) (*user.User, error)
- type ServiceInterface
- type SignInRequest
- type SignOutRequest
- type SignUpRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthResponse ¶
type AuthResponse = responses.AuthResponse
AuthResponse represents an authentication response
type Config ¶
type Config struct {
RequireEmailVerification bool `json:"requireEmailVerification"`
}
Config represents authentication configuration
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides authentication operations
func NewService ¶
func NewService(users user.ServiceInterface, session session.ServiceInterface, cfg Config) *Service
NewService creates a new auth service
func (*Service) CheckCredentials ¶
CheckCredentials validates a user's credentials and returns the user without creating a session
func (*Service) CreateSessionForUser ¶
func (s *Service) CreateSessionForUser(ctx context.Context, u *user.User, remember bool, ip, ua string) (*responses.AuthResponse, error)
CreateSessionForUser creates a session for a given user and returns auth response
func (*Service) GetSession ¶
GetSession validates and returns session details
func (*Service) SignIn ¶
func (s *Service) SignIn(ctx context.Context, req *SignInRequest) (*responses.AuthResponse, error)
SignIn authenticates a user and returns a session
func (*Service) SignOut ¶
func (s *Service) SignOut(ctx context.Context, req *SignOutRequest) error
SignOut revokes a session
func (*Service) SignUp ¶
func (s *Service) SignUp(ctx context.Context, req *SignUpRequest) (*responses.AuthResponse, error)
SignUp registers a new user and returns a session
type ServiceInterface ¶
type ServiceInterface interface {
SignUp(ctx context.Context, req *SignUpRequest) (*responses.AuthResponse, error)
SignIn(ctx context.Context, req *SignInRequest) (*responses.AuthResponse, error)
SignOut(ctx context.Context, req *SignOutRequest) error
CheckCredentials(ctx context.Context, email, password string) (*user.User, error)
CreateSessionForUser(ctx context.Context, u *user.User, remember bool, ipAddress, userAgent string) (*responses.AuthResponse, error)
GetSession(ctx context.Context, token string) (*responses.AuthResponse, error)
UpdateUser(ctx context.Context, id xid.ID, req *user.UpdateUserRequest) (*user.User, error)
}
ServiceInterface defines the contract for auth service operations This allows plugins to decorate the service with additional behavior
type SignInRequest ¶
type SignInRequest struct {
Email string
Password string
Remember bool
// Optional alternative naming per docs
RememberMe bool
IPAddress string
UserAgent string
}
SignInRequest represents a signin request
type SignOutRequest ¶
type SignOutRequest struct {
Token string
}
SignOutRequest represents a signout request