userrepo

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: BSD-2-Clause Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailConfirmation

type EmailConfirmation struct {
	Token      string
	Email      string
	ExpiryTime time.Time
	Confirmed  bool
}

type PasswordResetRequest

type PasswordResetRequest struct {
	Token      string
	Email      string
	ExpiryTime time.Time
	Confirmed  bool
}

type Session

type Session struct {
	Token      string
	UserUUID   string
	ExpiryTime time.Time
}

Session struct for storing session information in the database

type User

type User struct {
	UserUUID  string
	UserName  string
	Email     string
	Active    bool
	Status    string
	Passwd    string // Salted + bcrypted
	FirstName string
	LastName  string
	Role      string
}

type UserRepository

type UserRepository interface {
	Create(user *User) error
	Update(user *User) error
	Delete(userUUID string) error
	GetByUUID(userUUID string) (*User, error)
	GetByEmail(email string) (*User, error)
	List() ([]*User, error)
}

type UserRepositorySqlite

type UserRepositorySqlite struct {
	// contains filtered or unexported fields
}

func NewUserRepositorySqlite

func NewUserRepositorySqlite(dbPath string) (*UserRepositorySqlite, error)

func (*UserRepositorySqlite) ConfirmEmail

func (r *UserRepositorySqlite) ConfirmEmail(token string) error

This method takes a token string, queries the email_confirmations table for the corresponding record, and scans the result into a new EmailConfirmation struct. If the token is not found, it returns an error. If there's any other error during the query, it returns an error as well.

func (*UserRepositorySqlite) Create

func (repo *UserRepositorySqlite) Create(user User) error

func (*UserRepositorySqlite) CreateEmailConfirmation

func (r *UserRepositorySqlite) CreateEmailConfirmation(email string, expiryTime time.Time) (EmailConfirmation, error)

This method takes an email address and a token duration, generates a new email confirmation token, creates a new EmailConfirmation struct with the required fields, and inserts the record into the email_confirmations table. Add a new GetEmailConfirmation method to the `UserRepository

func (*UserRepositorySqlite) CreatePasswordResetRequest

func (r *UserRepositorySqlite) CreatePasswordResetRequest(email string, expiryTime time.Time) (PasswordResetRequest, error)

func (*UserRepositorySqlite) CreateSession

func (r *UserRepositorySqlite) CreateSession(userUUID string) (Session, error)

func (*UserRepositorySqlite) Delete

func (repo *UserRepositorySqlite) Delete(userUUID string) error

func (*UserRepositorySqlite) DeletePasswordResetRequest

func (r *UserRepositorySqlite) DeletePasswordResetRequest(token string) error

func (*UserRepositorySqlite) DeleteSession

func (r *UserRepositorySqlite) DeleteSession(token string) error

DeleteSession deletes a session by token

func (*UserRepositorySqlite) GetByEmail

func (repo *UserRepositorySqlite) GetByEmail(email string) (User, error)

func (*UserRepositorySqlite) GetByUUID

func (repo *UserRepositorySqlite) GetByUUID(userUUID string) (User, error)

func (*UserRepositorySqlite) GetByUserName

func (repo *UserRepositorySqlite) GetByUserName(userName string) (User, error)

func (*UserRepositorySqlite) GetEmailConfirmation

func (r *UserRepositorySqlite) GetEmailConfirmation(token string) (*EmailConfirmation, error)

func (*UserRepositorySqlite) GetPasswordResetRequest

func (r *UserRepositorySqlite) GetPasswordResetRequest(token string) (PasswordResetRequest, error)

func (*UserRepositorySqlite) GetSession

func (r *UserRepositorySqlite) GetSession(token string) (Session, error)

GetSession get a session by token

func (*UserRepositorySqlite) Signup

func (r *UserRepositorySqlite) Signup(user User) error

func (*UserRepositorySqlite) Update

func (repo *UserRepositorySqlite) Update(user User) error

Jump to

Keyboard shortcuts

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