Documentation ¶
Overview ¶
Package users represents the user resource
Index ¶
- Constants
- func Admins() *query.Query
- func AllowedParams() []string
- func Editors() *query.Query
- func Published() *query.Query
- func Query() *query.Query
- func Readers() *query.Query
- func Where(format string, args ...interface{}) *query.Query
- type User
- func (u *User) Admin() bool
- func (u *User) Anon() bool
- func (u *User) CanComment() bool
- func (u *User) CanDownvote() bool
- func (u *User) CanFlag() bool
- func (u *User) CanStyle() bool
- func (u *User) CanSubmit() bool
- func (u *User) CanUpvote() bool
- func (u *User) Reader() bool
- func (u *User) RoleDisplay() string
- func (u *User) RoleID() int64
- func (u *User) RoleOptions() []helpers.Option
- func (u *User) UserID() int64
Constants ¶
const ( // TableName is the database table for this resource TableName = "users" // KeyName is the primary key value for this resource KeyName = "id" // Order defines the default sort order in sql for this resource Order = "name asc, id desc" )
const ( Anon = 0 Editor = 10 Reader = 20 Admin = 100 )
User roles
Variables ¶
This section is empty.
Functions ¶
func AllowedParams ¶
func AllowedParams() []string
AllowedParams returns an array of acceptable params in update
Types ¶
type User ¶
type User struct { // resource.Base defines behaviour and fields shared between all resources resource.Base // status.ResourceStatus defines a status field and associated behaviour status.ResourceStatus Email string Name string Points int64 Role int64 Summary string Text string Title string PasswordHash string PasswordResetAt time.Time }
User handles saving and retreiving users from the database
func FindFirst ¶ added in v1.0.1
FindFirst fetches a single user record from the database using a where query with the format and args provided.
func MockAdmin ¶ added in v1.0.1
func MockAdmin() *User
MockAdmin returns a mock user for testing with Role Admin.
func MockAnon ¶ added in v1.0.1
func MockAnon() *User
MockAnon returns a mock user for testing with Role Anon.
func NewWithColumns ¶
NewWithColumns creates a new user instance and fills it with data from the database cols provided.
func (*User) CanComment ¶
CanComment returns true if this user can comment.
func (*User) CanDownvote ¶
CanDownvote returns true if this user can downvote.
func (*User) CanStyle ¶ added in v1.0.1
CanStyle returns true if this user can style text in comments/stories.
func (*User) RoleDisplay ¶
RoleDisplay returns the string representation of the Role status
func (*User) RoleOptions ¶
RoleOptions returns an array of Role values for this model (embedders may override this and roledisplay to extend)