user_model

package
v0.0.0-...-076d96f Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2012 License: BSD-2-Clause-Views Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildUser

func BuildUser(db *mgo.Database, ev ifaces.Event, user_id bson.ObjectId, http_header map[string][]string) (map[string]interface{}, error)

Builds a user from his Id and information in http_header.

func Decrypt

func Decrypt(val string, block_key []byte) (string, error)

Decrypts a string with block_key. Also decodes val from base64. This is put here as a separate function (has no public Encrypt pair) to be able to separate the decryption of the cookie into a user_id (see DecryptId)

func DecryptId

func DecryptId(cookieval string, block_key []byte) (bson.ObjectId, error)

cookieval is encrypted Converts an encoded string (a cookie) into an ObjectId.

func EmptyUser

func EmptyUser() map[string]interface{}

When no user cookie is found, or there was a problem during building the user, we proceed with an empty user.

func EncodePass

func EncodePass(pass string) string

This is public because the admin_model.RegUser needs it.

func FindLogin

func FindLogin(db *mgo.Database, inp map[string][]string) (map[string]interface{}, bson.ObjectId, error)

Everyone uses this to log in, admins, users, guest users and their mom.

func FindUser

func FindUser(db *mgo.Database, id interface{}) (map[string]interface{}, error)

Finds a user by id.

func InterpretPuzzleGroup

func InterpretPuzzleGroup(puzzle_group []interface{}) (puzzles []string, can_fail int)

Interpret puzzle group. Example puzzle_group: pg := []interface{}{"hashcash", "captcha", 1} This means "Solve hashcash and captcha. One of the puzzles may fail." This allows one to serve hashcash to those who have javascript enabled and fall back to captchas for those who don't.

func Login

func Login(w http.ResponseWriter, user_id bson.ObjectId, block_key []byte) error

Sets a cookie to w named "user" with a value of the encoded user_id. Admins, guests, registered users, everyone logs in with this.

func NameAvailable

func NameAvailable(db *mgo.Database, name string) (bool, error)

Returns true if the username is still available (eg: no one is registered with that name).

func ParseAcceptLanguage

func ParseAcceptLanguage(l string) (ret []string)

Creates a list of 2 char language abbreviations (for example: []string{"en", "de", "hu"}) out of the value of http header "Accept-Language".

func RegisterGuest

func RegisterGuest(db *mgo.Database, ev ifaces.Event, guest_rules map[string]interface{}, inp map[string][]string, solved_puzzle bool) (bson.ObjectId, error)

Quickly register someone when he does an action as a guest. guest_rules can be nil.

func RegisterUser

func RegisterUser(db *mgo.Database, ev ifaces.Event, rules map[string]interface{}, inp map[string][]string) (bson.ObjectId, error)

Registers a normal user with password and level 100. See RegisterGuest for an other kind of registration. See admin_model for registrations of admins.

func ShowHashcash

func ShowHashcash(secret string, puzzle_opts map[string]interface{}) (string, error)

func ShowHoneypot

func ShowHoneypot(secret string, puzzle_opts map[string]interface{}) (string, error)

func ShowTimer

func ShowTimer(secret string, puzzle_opts map[string]interface{}) (string, error)

func SolveHashcash

func SolveHashcash(secret string, inp map[string][]string, puzzle_opts map[string]interface{}) error

func SolveHoneypot

func SolveHoneypot(secret string, inp map[string][]string, puzzle_opts map[string]interface{}) error

func SolveTimer

func SolveTimer(secret string, inp map[string][]string, puzzle_opts map[string]interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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