Documentation ¶
Index ¶
- type Client
- func (c *Client) Device() auth.DeviceRepository
- func (c *Client) LoginHistory() auth.LoginHistoryRepository
- func (c *Client) NewWithTransaction(ctx context.Context) (auth.RepositoryManager, error)
- func (c *Client) User() auth.UserRepository
- func (c *Client) WithAtomic(operation func() (interface{}, error)) (interface{}, error)
- type ConfigOption
- type DeviceRepository
- func (r *DeviceRepository) ByClientID(ctx context.Context, userID string, clientID []byte) (*auth.Device, error)
- func (r *DeviceRepository) ByID(ctx context.Context, deviceID string) (*auth.Device, error)
- func (r *DeviceRepository) ByUserID(ctx context.Context, userID string) ([]*auth.Device, error)
- func (r *DeviceRepository) Create(ctx context.Context, device *auth.Device) error
- func (r *DeviceRepository) GetForUpdate(ctx context.Context, deviceID string) (*auth.Device, error)
- func (r *DeviceRepository) Remove(ctx context.Context, deviceID, userID string) error
- func (r *DeviceRepository) Update(ctx context.Context, device *auth.Device) error
- type LoginHistoryRepository
- func (r *LoginHistoryRepository) ByTokenID(ctx context.Context, tokenID string) (*auth.LoginHistory, error)
- func (r *LoginHistoryRepository) ByUserID(ctx context.Context, userID string, limit, offset int) ([]*auth.LoginHistory, error)
- func (r *LoginHistoryRepository) Create(ctx context.Context, login *auth.LoginHistory) error
- func (r *LoginHistoryRepository) GetForUpdate(ctx context.Context, tokenID string) (*auth.LoginHistory, error)
- func (r *LoginHistoryRepository) Update(ctx context.Context, login *auth.LoginHistory) error
- type UserRepository
- func (r *UserRepository) ByIdentity(ctx context.Context, attribute, value string) (*auth.User, error)
- func (r *UserRepository) Create(ctx context.Context, user *auth.User) error
- func (r *UserRepository) DisableOTP(ctx context.Context, userID string, method auth.DeliveryMethod) (*auth.User, error)
- func (r *UserRepository) GetForUpdate(ctx context.Context, userID string) (*auth.User, error)
- func (r *UserRepository) ReCreate(ctx context.Context, user *auth.User) error
- func (r *UserRepository) RemoveDeliveryMethod(ctx context.Context, userID string, method auth.DeliveryMethod) (*auth.User, error)
- func (r *UserRepository) Update(ctx context.Context, user *auth.User) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client for PostgreSQL.
func NewClient ¶
func NewClient(options ...ConfigOption) *Client
NewClient returns a new Postgres client to manage repositories.
func TestClient ¶
TestClient returns a test client with necessary dependencies already provided.
func (*Client) Device ¶
func (c *Client) Device() auth.DeviceRepository
Device returns a DeviceRepository.
func (*Client) LoginHistory ¶
func (c *Client) LoginHistory() auth.LoginHistoryRepository
LoginHistory returns a LoginRepository.
func (*Client) NewWithTransaction ¶
NewWithTransaction returns a new client with a transaction. All repository operations using the new client will default to the transaction.
func (*Client) WithAtomic ¶
WithAtomic performs an operation within a transaction. If the operation is successful it commits it, otherwise the operation will be rolledback.
type ConfigOption ¶
type ConfigOption func(*Client)
ConfigOption configures the Client.
func WithLogger ¶
func WithLogger(l log.Logger) ConfigOption
WithLogger configures the client with a Logger.
func WithPassword ¶
func WithPassword(p auth.PasswordService) ConfigOption
WithPassword configures the client with a PasswordService.
type DeviceRepository ¶
type DeviceRepository struct {
// contains filtered or unexported fields
}
DeviceRepository is an implementation of auth.DeviceRepository interface.
func (*DeviceRepository) ByClientID ¶
func (r *DeviceRepository) ByClientID(ctx context.Context, userID string, clientID []byte) (*auth.Device, error)
ByClientID retrieves a Device with a matching ClientID.
func (*DeviceRepository) GetForUpdate ¶
GetForUpdate retrieves a Device to be updated.
type LoginHistoryRepository ¶
type LoginHistoryRepository struct {
// contains filtered or unexported fields
}
LoginHistoryRepository is an implementation of auth.LoginHistoryRepository.
func (*LoginHistoryRepository) ByTokenID ¶
func (r *LoginHistoryRepository) ByTokenID(ctx context.Context, tokenID string) (*auth.LoginHistory, error)
ByTokenID retrieves a LoginHistory record with matching JWT token ID.
func (*LoginHistoryRepository) ByUserID ¶
func (r *LoginHistoryRepository) ByUserID(ctx context.Context, userID string, limit, offset int) ([]*auth.LoginHistory, error)
ByUserID retrieves all LoginHistory records associated with a User.
func (*LoginHistoryRepository) Create ¶
func (r *LoginHistoryRepository) Create(ctx context.Context, login *auth.LoginHistory) error
Create persists a new LoginHistory to storage.
func (*LoginHistoryRepository) GetForUpdate ¶
func (r *LoginHistoryRepository) GetForUpdate(ctx context.Context, tokenID string) (*auth.LoginHistory, error)
GetForUpdate retrieves a LoginHistory to be updated.
func (*LoginHistoryRepository) Update ¶
func (r *LoginHistoryRepository) Update(ctx context.Context, login *auth.LoginHistory) error
Update updates a LoginHistory in storage.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository is an implementation of auth.UserRepository.
func (*UserRepository) ByIdentity ¶
func (r *UserRepository) ByIdentity(ctx context.Context, attribute, value string) (*auth.User, error)
ByIdentity retrieves a User by their phone, email, or unique ID.
func (*UserRepository) DisableOTP ¶
func (r *UserRepository) DisableOTP(ctx context.Context, userID string, method auth.DeliveryMethod) (*auth.User, error)
DisableOTP disables an OTP delivery method for a User.
func (*UserRepository) GetForUpdate ¶
GetForUpdate retrieves a User to be updated.
func (*UserRepository) ReCreate ¶
ReCreate updates an existing unverified User record with new a new creation timestamp and primary key value to treat the user as a newly created record. New Users remain in an unverified state until completing OTP verification to prove ownership of a phone or email address.
func (*UserRepository) RemoveDeliveryMethod ¶
func (r *UserRepository) RemoveDeliveryMethod(ctx context.Context, userID string, method auth.DeliveryMethod) (*auth.User, error)
RemoveDeliveryMethod removes a phone or email from a User.