users

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package users represents a logged in user

Index

Constants

View Source
const (
	RoleAnon   = 0
	RoleReader = 20
	RoleEditor = 50
	RoleAdmin  = 100
)

Role constants for this package

Variables

This section is empty.

Functions

func Admins

func Admins() *query.Query

Admins returns a query which finds all admin users

func AllowedParams

func AllowedParams() []string

AllowedParams returns an array of acceptable params in update

func AllowedParamsAdmin

func AllowedParamsAdmin() []string

AllowedParamsAdmin returns an array of acceptable params in update for admins

func Create

func Create(params map[string]string) (int64, error)

Create inserts a new user

func Editors

func Editors() *query.Query

Editors returns a query which finds all editor users

func Exists

func Exists(e string) bool

Exists checks whether a user email exists

func Query

func Query() *query.Query

Query a new query relation referencing this model, optionally setting a default order

func Readers

func Readers() *query.Query

Readers returns a query which finds all reader users

func Where

func Where(format string, args ...interface{}) *query.Query

Where is a shortcut for the common where query on users

Types

type User

type User struct {
	model.Model
	status.ModelStatus
	Role              int64
	EncryptedPassword string
	Email             string
	Name              string
	Title             string
	Summary           string
	Text              string
	Points            int64
}

User represents a user of the service

func Find

func Find(id int64) (*User, error)

Find fetches a single record by id

func FindAll

func FindAll(q *query.Query) ([]*User, error)

FindAll fetches all results for this query

func FindEmail

func FindEmail(email string) (*User, error)

FindEmail fetches a single record by email

func First

func First(q *query.Query) (*User, error)

First fetches the first result for this query

func New

func New() *User

New sets up a new user with default values

func NewWithColumns

func NewWithColumns(cols map[string]interface{}) *User

NewWithColumns creates a user from database columns - used by query in creating objects

func (*User) Admin

func (m *User) Admin() bool

Admin returns true if this user is Admin

func (*User) Anon

func (m *User) Anon() bool

Anon returns true if this user is anon

func (*User) CanComment

func (u *User) CanComment() bool

CanComment returns true if this user can comment

func (*User) CanDownvote

func (u *User) CanDownvote() bool

CanDownvote returns true if this user can downvote

func (*User) CanFlag

func (u *User) CanFlag() bool

CanFlag returns true if this user can flag

func (*User) CanSubmit

func (u *User) CanSubmit() bool

CanSubmit returns true if this user can submit

func (*User) CanUpvote

func (u *User) CanUpvote() bool

CanUpvote returns true if this user can upvote TODO: change later - just let all users upvote for now

func (*User) Destroy

func (m *User) Destroy() error

Destroy this user

func (*User) Editor

func (m *User) Editor() bool

Editor returns true if this user is Expert

func (*User) Keywords

func (m *User) Keywords() string

Keywords returns meta keywords for this user

func (*User) Reader

func (m *User) Reader() bool

Reader returns true if this user is Patient

func (*User) RoleDisplay

func (m *User) RoleDisplay() string

RoleDisplay returns the string representation of the Role status

func (*User) RoleOptions

func (m *User) RoleOptions() []helpers.Option

RoleOptions returns an array of Role values for this model (embedders may override this and roledisplay to extend)

func (*User) SelectName

func (m *User) SelectName() string

SelectName returns the name which should be used for select options

func (*User) URLShow

func (m *User) URLShow() string

URLShow returns the url for this user

func (*User) Update

func (m *User) Update(params map[string]string) error

Update this user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL