Documentation ¶
Index ¶
- Variables
- func AddRole(projectID int, userID string, canWrite bool) error
- func ChangeUserPassword(id string, newPassword string) error
- func CheckPasswordHash(password, hash string) bool
- func DeleteDocument(id int) error
- func DeleteProject(id int) error
- func DeleteRole(projectID int, userID string) error
- func DeleteUser(id string) error
- func Finalize()
- func GetSHA256Hex(data []byte) string
- func HashPassword(password string) (string, error)
- func Init()
- func LoadAllProjectIDs() ([]int, error)
- func LoadProjectIDsForUser(userID string) ([]int, error)
- func LoggerMiddleware() func(*gin.Context)
- func PanicRecoveryMiddleware() func(*gin.Context)
- func UpdateDocument(id int, title string, body string, sortOrder int) error
- func UpdateProject(id int, title string, description string) error
- func UpdateRole(projectID int, userID string, canWrite bool) error
- func UpdateUser(id string, username string, admin bool) error
- func UserFindIDByUserName(username string) (id string, err error)
- type Document
- type Project
- type Role
- type User
Constants ¶
This section is empty.
Variables ¶
var DB *sql.DB
DB database instance
var ErrAuthenticationFailed = errors.New("authentication failed")
ErrAuthenticationFailed --
var ErrRoleNotFound = errors.New("role not found")
ErrRoleNotFound --
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound --
var ErrUsernameAlreadyExists = errors.New("username already exists")
ErrUsernameAlreadyExists --
var Logger *zap.SugaredLogger
Logger zap sugared logger instance
var LoggerCore *zap.Logger
LoggerCore zap base logger instance
Functions ¶
func ChangeUserPassword ¶
ChangeUserPassword --
func CheckPasswordHash ¶
CheckPasswordHash makes the hash from the password and compares to the input password
func GetSHA256Hex ¶
GetSHA256Hex returns the sha256 hash of a []byte in hex format
func HashPassword ¶
HashPassword makes the hash of the password using bcrypt
func LoadProjectIDsForUser ¶
LoadProjectIDsForUser --
func LoggerMiddleware ¶
LoggerMiddleware gin middleware to log the requests
func PanicRecoveryMiddleware ¶
PanicRecoveryMiddleware gin middleware to recover from panic and log the error
func UpdateDocument ¶
UpdateDocument --
func UpdateProject ¶
UpdateProject --
func UpdateUser ¶
UpdateUser fields: Username, Admin
func UserFindIDByUserName ¶
UserFindIDByUserName returns the id of the user
Types ¶
type Document ¶
type Document struct { CreatedAt time.Time UpdatedAt time.Time ID int ProjectID int Title string SortOrder int Body string }
Document document model
func CreateDocument ¶
func CreateDocument(projectID int, title string, body string, sortOrder int) (document *Document, err error)
CreateDocument --
func LoadDocuments ¶
LoadDocuments loads all the documents of a project
type Project ¶
type Project struct { CreatedAt time.Time UpdatedAt time.Time ID int Title string Description string }
Project project model
func CreateProject ¶
CreateProject --
type User ¶
User user model
func AuthenticateUser ¶
AuthenticateUser --
func CreateUser ¶
CreateUser --