Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateChangePassword(v *validator.Validator, currentpassword, newpassword, confirmpassword string)
- func ValidateEmail(v *validator.Validator, email string)
- func ValidateFilters(v *validator.Validator, f Filters)
- func ValidateMovie(v *validator.Validator, movie *Movie)
- func ValidatePasswordPlaintext(v *validator.Validator, password string)
- func ValidateProfilePicture(v *validator.Validator, fileHeaderSize int64, ext string, file multipart.File) (image.Image, error)
- func ValidateTokenPlaintext(v *validator.Validator, tokenPlaintext string)
- func ValidateUser(v *validator.Validator, user *User)
- type Filters
- type Metadata
- type Models
- type Movie
- type MovieModel
- type Password
- type PermissionModel
- type Permissions
- type ProfileModel
- type Runtime
- type Token
- type TokenModel
- type User
- type UserModel
- func (m UserModel) ChangePassword(id int64, newPassword string) error
- func (m UserModel) Delete(id int64) error
- func (m UserModel) GetByEmail(email string) (*User, error)
- func (m UserModel) GetForToken(tokenScope, tokenPlaintext string) (*User, error)
- func (m UserModel) Insert(user *User) error
- func (m UserModel) Update(user *User) error
- type UserProfile
Constants ¶
View Source
const ( ScopeActivation = "activation" ScopeAuthentication = "authentication" ScopePasswordReset = "password-reset" )
Variables ¶
View Source
var ( ErrRecordNotFound = errors.New("record not found") ErrEditConflict = errors.New("edit conflict") ErrInvalidCredentials = errors.New("invalid credentials") )
View Source
var AnonymousUser = &User{}
View Source
var (
ErrDuplicateEmail = errors.New("duplicate email")
)
View Source
var (
ErrDuplicatePermission = errors.New("duplicate permission made")
)
View Source
var (
ErrDuplicateProfile = errors.New("duplicate profile")
)
View Source
var ErrInvalidRuntimeFormat = errors.New("invalid runtime format")
Functions ¶
func ValidateChangePassword ¶
func ValidateEmail ¶
func ValidateFilters ¶
func ValidateMovie ¶
func ValidateProfilePicture ¶
func ValidateTokenPlaintext ¶
func ValidateUser ¶
Types ¶
type Models ¶
type Models struct {
Movies interface {
Insert(movie *Movie) error
Get(id int64) (*Movie, error)
Update(movie *Movie) error
Delete(id int64) error
GetAll(title string, genres []string, filters Filters) ([]*Movie, Metadata, error)
}
Tokens interface {
Insert(token *Token) error
DeleteAllForUser(scope string, userID int64, userIP *string) error
New(userID int64, ttl time.Duration, scope string, r *http.Request) (*Token, error)
}
Users interface {
Insert(user *User) error
GetByEmail(email string) (*User, error)
Update(user *User) error
GetForToken(tokenScope, tokenPlaintext string) (*User, error)
ChangePassword(id int64, newPassword string) error
Delete(id int64) error
}
Permissions interface {
GetAllForUser(userID int64) (Permissions, error)
AddForUser(userID int64, codes ...string) error
}
UsersProfile interface {
Insert(profile *UserProfile) error
Update(profile *UserProfile) error
InsertProfilePic(userID int64) error
Get(userID int64) (*UserProfile, error)
DeletOldPicture(imagePath string) error
}
}
type MovieModel ¶
func (MovieModel) Delete ¶
func (m MovieModel) Delete(id int64) error
func (MovieModel) Insert ¶
func (m MovieModel) Insert(movie *Movie) error
func (MovieModel) Update ¶
func (m MovieModel) Update(movie *Movie) error
type PermissionModel ¶
func (PermissionModel) AddForUser ¶
func (m PermissionModel) AddForUser(userID int64, codes ...string) error
func (PermissionModel) GetAllForUser ¶
func (m PermissionModel) GetAllForUser(userID int64) (Permissions, error)
type Permissions ¶
type Permissions []string
func (Permissions) Include ¶
func (p Permissions) Include(code string) bool
type ProfileModel ¶
func (ProfileModel) DeletOldPicture ¶
func (p ProfileModel) DeletOldPicture(imagePath string) error
func (ProfileModel) Get ¶
func (p ProfileModel) Get(userID int64) (*UserProfile, error)
func (ProfileModel) Insert ¶
func (p ProfileModel) Insert(profile *UserProfile) error
func (ProfileModel) InsertProfilePic ¶
func (p ProfileModel) InsertProfilePic(userID int64) error
func (ProfileModel) Update ¶
func (p ProfileModel) Update(profile *UserProfile) error
type TokenModel ¶
func (TokenModel) DeleteAllForUser ¶
func (m TokenModel) DeleteAllForUser(scope string, userID int64, userIP *string) error
func (TokenModel) Insert ¶
func (m TokenModel) Insert(token *Token) error
type User ¶
type User struct {
ID int64 `json:"id"`
CreatedAt time.Time `json:"created_at"`
Name string `json:"name"`
Email string `json:"email"`
Password Password `json:"-"`
Activated bool `json:"activated"`
Admin bool `json:"admin"`
Version int `json:"-"`
}
func (*User) IsAnonymous ¶
type UserProfile ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.