Documentation
¶
Index ¶
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func ForgotPasswordGetHandler(ctx *enliven.Context)
- func ForgotPasswordPostHandler(ctx *enliven.Context)
- func GeneratePasswordHash(password string, cost ...int) string
- func LoginGetHandler(ctx *enliven.Context)
- func LoginPostHandler(ctx *enliven.Context)
- func LogoutHandler(ctx *enliven.Context)
- func MustAsset(name string) []byte
- func PasswordResetGetHandler(ctx *enliven.Context)
- func PasswordResetPostHandler(ctx *enliven.Context)
- func ProfileGetHandler(ctx *enliven.Context)
- func ProfilePostHandler(ctx *enliven.Context)
- func RegisterGetHandler(ctx *enliven.Context)
- func RegisterPostHandler(ctx *enliven.Context)
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func SessionMiddleware(ctx *enliven.Context, next enliven.NextHandlerFunc)
- func VerifyHandler(ctx *enliven.Context)
- func VerifyPasswordHash(hash string, password string) bool
- type App
- type FormError
- type Group
- type Permission
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/
foo.txt
img/
a.png
b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func ForgotPasswordGetHandler ¶
ForgotPasswordGetHandler Allows a user to enter their email address to have their password reset
func ForgotPasswordPostHandler ¶
ForgotPasswordPostHandler accepts a posted email address which we'll send a new verification code to so they can reset their password
func GeneratePasswordHash ¶
GeneratePasswordHash produces a bcrypt hash and returns it
func LoginGetHandler ¶
LoginGetHandler handles get requests to the login route
func LoginPostHandler ¶
LoginPostHandler handles the form submission for logging a user in.
func LogoutHandler ¶
LogoutHandler logs a user out and redirects them to the configured page.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func PasswordResetGetHandler ¶
PasswordResetGetHandler checks if a password reset code is legit, and presents the user with a password reset form.
func PasswordResetPostHandler ¶
PasswordResetPostHandler checks if a password reset code is legit, and and resets the users password to what has been posted.
func ProfileGetHandler ¶
ProfileGetHandler displays the profile editor
func ProfilePostHandler ¶
ProfilePostHandler handles the updating of a user's profile
func RegisterGetHandler ¶
RegisterGetHandler handles get requests to the register route
func RegisterPostHandler ¶
RegisterPostHandler handles get requests to the register route
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func SessionMiddleware ¶
func SessionMiddleware(ctx *enliven.Context, next enliven.NextHandlerFunc)
SessionMiddleware handles adding the elements to the context that carry the user's id and status
func VerifyHandler ¶
VerifyHandler checks a user's verification code to see if it matches.
func VerifyPasswordHash ¶
VerifyPasswordHash checks a password for validity
Types ¶
type App ¶
type App struct{}
App handles adding a route handler for static assets
func (*App) AddPermission ¶
AddPermission adds a new permission to the user table if it doesn't exist
func (*App) HasPermission ¶
HasPermission checks if a user has a permission matching the permission string passed in
func (*App) Initialize ¶
Initialize sets up our app to handle embedded static asset requests
type Group ¶
type Group struct {
gorm.Model
Name string `gorm:"not null;unique;"`
Permissions []Permission `gorm:"many2many:group_permission;"`
}
Group describes the user group database structure
type Permission ¶
Permission describes a permission that can be linked to many groups
type User ¶
type User struct {
gorm.Model
DisplayName string
Username string `gorm:"type:varchar(100);unique_index;"`
Email string `gorm:"type:varchar(100);unique_index;"`
Password string `gorm:"type:varchar(100);"`
VerificationCode string `gorm:"type:varchar(64);index;"`
Status int `gorm:"default:0;"`
Groups []Group `gorm:"many2many:user_group;"`
Superuser bool `gorm:"index;"`
}
User describes the user database structure.
func (*User) GetDisplayName ¶
GetDisplayName gets the proper display name for a user.
func (*User) UserHasPermission ¶
UserHasPermission checks if a user has a specific permission