Documentation ¶
Index ¶
- func BuildUser(db *mgo.Database, ev ifaces.Event, user_id bson.ObjectId, ...) (map[string]interface{}, error)
- func Decrypt(val string, block_key []byte) (string, error)
- func DecryptId(cookieval string, block_key []byte) (bson.ObjectId, error)
- func EmptyUser() map[string]interface{}
- func EncodePass(pass string) string
- func FindLogin(db *mgo.Database, inp map[string][]string) (map[string]interface{}, bson.ObjectId, error)
- func FindUser(db *mgo.Database, id interface{}) (map[string]interface{}, error)
- func InterpretPuzzleGroup(puzzle_group []interface{}) (puzzles []string, can_fail int)
- func Login(w http.ResponseWriter, user_id bson.ObjectId, block_key []byte) error
- func NameAvailable(db *mgo.Database, name string) (bool, error)
- func ParseAcceptLanguage(l string) (ret []string)
- func RegisterGuest(db *mgo.Database, ev ifaces.Event, guest_rules map[string]interface{}, ...) (bson.ObjectId, error)
- func RegisterUser(db *mgo.Database, ev ifaces.Event, rules map[string]interface{}, ...) (bson.ObjectId, error)
- func ShowHashcash(secret string, puzzle_opts map[string]interface{}) (string, error)
- func ShowHoneypot(secret string, puzzle_opts map[string]interface{}) (string, error)
- func ShowTimer(secret string, puzzle_opts map[string]interface{}) (string, error)
- func SolveHashcash(secret string, inp map[string][]string, puzzle_opts map[string]interface{}) error
- func SolveHoneypot(secret string, inp map[string][]string, puzzle_opts map[string]interface{}) error
- func SolveTimer(secret string, inp map[string][]string, puzzle_opts map[string]interface{}) error
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 ¶
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 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 ¶
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 InterpretPuzzleGroup ¶
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 ¶
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 ¶
Returns true if the username is still available (eg: no one is registered with that name).
func ParseAcceptLanguage ¶
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 ShowHoneypot ¶
func SolveHashcash ¶
func SolveHoneypot ¶
Types ¶
This section is empty.