Documentation ¶
Index ¶
- Constants
- Variables
- type Repository
- type Store
- func (s *Store) CheckSession(token string) error
- func (s *Store) Create(u domain.UserCreate) (domain.User, error)
- func (s *Store) Delete(id int) error
- func (s *Store) Exists(id int) bool
- func (s *Store) ExistsByEmail(email string) bool
- func (s *Store) Find(id int) (domain.User, error)
- func (s *Store) FindByEmail(email string) (domain.User, error)
- func (s *Store) FindByToken(token string) (domain.User, error)
- func (s *Store) List(meta params.Params, role string) (domain.Users, int, error)
- func (s *Store) Owner() domain.User
- func (s *Store) ResetPassword(id int, reset domain.UserPasswordReset) error
- func (s *Store) Update(u domain.User) (domain.User, error)
- func (s *Store) UpdateToken(token string) error
Constants ¶
const ( // The database table name for users. TableName = "users" // The database table name for the user-roles pivot. PivotTableName = "user_roles" )
Variables ¶
var ( // ErrUserExists is returned by validate when // a user already exists. ErrUserExists = errors.New("user already exists") // ErrDeleteOwner is returned by delete when // the owner id has been passed. ErrDeleteOwner = errors.New("owner cannot be deleted") // ErrSessionExpired is returned by check session // when the user session has gone passed the // inactive session time. ErrSessionExpired = errors.New("session expired") )
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository interface { List(meta params.Params, role string) (domain.Users, int, error) Find(id int) (domain.User, error) FindByToken(token string) (domain.User, error) FindByEmail(email string) (domain.User, error) Owner() domain.User Create(u domain.UserCreate) (domain.User, error) Update(u domain.User) (domain.User, error) Delete(id int) error CheckSession(token string) error ResetPassword(id int, reset domain.UserPasswordReset) error UpdateToken(token string) error Exists(id int) bool ExistsByEmail(email string) bool }
Repository defines methods for users to interact with the database.
type Store ¶
Store defines the data layer for users.
func (*Store) CheckSession ¶
CheckSession
Returns nil if the session is valid. Returns errors.NOTFOUND if the user was not found. Returns errors.CONFLICT if the user session expired. Returns errors.INTERNAL if the SQL query was invalid.
func (*Store) Create ¶
Create
Returns a new category upon creation. Returns errors.CONFLICT if the the category (name) already exists. Returns errors.INTERNAL if the SQL query was invalid or the function could not get the newly created ID.
func (*Store) Delete ¶
Delete
Returns nil if the user was successfully deleted. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.NOTFOUND if the category was not found.
func (*Store) Exists ¶
Exists
Returns a bool indicating if the user exists by ID. Logs errors.INTERNAL if there was an error executing the query.
func (*Store) ExistsByEmail ¶
ExistsByEmail
Returns a bool indicating if the user exists by email. Logs errors.INTERNAL if there was an error executing the query.
func (*Store) Find ¶
Find
Returns a user by searching with the given ID. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the category was not found by the given ID.
func (*Store) FindByEmail ¶
FindByEmail
Returns a user by searching with the given email. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the category was not found by the given ID.
func (*Store) FindByToken ¶
FindByToken
Returns a user by searching with the given token. Returns errors.INTERNAL if there was an error executing the query. Returns errors.NOTFOUND if the category was not found by the given ID.
func (*Store) List ¶
List
Returns a slice of users with the total amount. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.NOTFOUND if there are no categories available.
func (*Store) Owner ¶
Owner
Returns a the owner of the installation. Logs errors.INTERNAL if there was an error executing the query. Logs errors.NOTFOUND if the category was not found by the given ID.
func (*Store) ResetPassword ¶
func (s *Store) ResetPassword(id int, reset domain.UserPasswordReset) error
ResetPassword
Returns nil if the password as reset successfully. Returns errors.INTERNAL if the SQL query was invalid. Returns errors.INVALID if the user could not be updated.
func (*Store) Update ¶
Update
Returns an updated user. Returns errors.CONFLICT if the validation failed. Returns errors.INTERNAL if the SQL query was invalid or the function could not obtain the newly created ID.
func (*Store) UpdateToken ¶
UpdateToken
Returns nil if the token last used column was successfully updated. Returns errors.INTERNAL if the sql query failed to execute or the token does not exist.