Documentation ¶
Index ¶
- Constants
- Variables
- func AddPermission(giver *models.User, userId uint64, permission *models.Permission) error
- func AuthorizeWithPassword(usernameOrEmail, password string) (*models.User, error)
- func AuthorizeWithToken(token string) (*models.User, error)
- func Clear() error
- func CommitDbMigrate(try func(*sql.DB) error)
- func ConnectToDb()
- func CreateToken(userId uint64) (string, error)
- func ExperimentDb(try func(*sql.DB) error)
- func GetAuthor(authorId uint64) (*models.Author, error)
- func GetBook(bookId uint64) (*models.Book, error)
- func GetImage(id uint64) ([]byte, string, error)
- func GetPermissions(user *models.User) ([]models.Permission, error)
- func GetUser(id uint64) (*models.User, error)
- func HasPermissions(user *models.User, permissions []models.Permission) (bool, error)
- func InsertAuthor(user *models.User, firstName string, lastName string) (uint64, error)
- func InsertBook(user *models.User, title string, description string) (uint64, error)
- func InsertImage(image []byte, extension string) (uint64, error)
- func InsertUser(username, email, password string, userGroup uint64) error
- func InsertValidateBook(user *models.User, title string, description string) (uint64, error)
- func InsertWrittenBy(user *models.User, authorId, bookId uint64) (uint64, error)
- func MergeAuthorInto(from uint64, into uint64) error
- func MergeBookInto(from uint64, into uint64) error
- func RemovePermissions(userId uint64, permission models.Permission) error
- func SelectAuthors(pageIndex uint64) ([]models.Author, error)
- func SelectBooks(pageIndex uint64) ([]models.Book, error)
- func SelectUsers(pageIndex uint64) ([]models.User, error)
- func UpdateProfilePic(user *models.User, imageId uint64) error
- func UpdateUser(user *models.User, username, email string) error
- func UpdateUserGroup(id uint64, userGroup uint64) error
- func UpdateUserPassword(user *models.User, oldPass, newPass string) error
- func ValidateAuthor(user *models.User, authorId uint64) error
- func ValidateBook(user *models.User, bookId uint64) error
- func ValidateWrittenBy(user *models.User, authorId, bookId uint64) error
Constants ¶
View Source
const CompatVersion = 1
version defines the current migration version. This ensures the app is always compatible with the version of the database.
Variables ¶
View Source
var ( IncorrectPassword = errors.New("password was incorrect") NonexistentUser = errors.New("user doesn't exist") InvalidToken = errors.New("token is not valid") ExpiredToken = errors.New("token has expired") )
View Source
var ( InvalidUsername = errors.New("username was invalid; must be 2-16 long, begin with a letter, and contain alphanumerics/underscores only") InvalidEmail = errors.New("email was in an invalid format") InvalidPassword = errors.New("password was invalid; must be 5-32 long") // https://www.alexedwards.net/blog/validation-snippets-for-go#email-validation InvalidPageSize = errors.New( "gave an invalid page size. Pages can between 50 and 100 entries long") )
Functions ¶
func AddPermission ¶
func AuthorizeWithPassword ¶
func CommitDbMigrate ¶
func ConnectToDb ¶
func ConnectToDb()
func CreateToken ¶
func ExperimentDb ¶
func GetPermissions ¶
func GetPermissions(user *models.User) ([]models.Permission, error)
func HasPermissions ¶
func InsertAuthor ¶
func InsertBook ¶
func InsertUser ¶
func InsertValidateBook ¶
func InsertWrittenBy ¶
func MergeAuthorInto ¶
func MergeBookInto ¶
func RemovePermissions ¶
func RemovePermissions(userId uint64, permission models.Permission) error
func UpdateUserGroup ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.