auth

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

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

func (s *Service) CheckCredentials(ctx context.Context, email, password string) (*user.User, error)

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

func (s *Service) GetSession(ctx context.Context, token string) (*responses.AuthResponse, error)

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

func (*Service) UpdateUser

func (s *Service) UpdateUser(ctx context.Context, userID xid.ID, req *user.UpdateUserRequest) (*user.User, error)

UpdateUser updates the current user's fields via user service

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

type SignUpRequest

type SignUpRequest struct {
	Email     string
	Password  string
	Name      string
	Remember  bool
	IPAddress string
	UserAgent string
}

SignUpRequest represents a signup request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL