Documentation ¶
Index ¶
- Constants
- func GenString(size int) string
- type DBM
- func (db *DBM) AddUser(username, password, email, first, last, data, tokens string, cost int) (*User, error)
- func (db *DBM) Connect(name string) error
- func (db *DBM) ConnectionString() string
- func (db *DBM) Create(name string) error
- func (db *DBM) DatabaseExists(name string) bool
- func (db *DBM) DeleteUser(id int64) error
- func (db *DBM) DeleteUserByName(name string) error
- func (db *DBM) Drop(name string) error
- func (db *DBM) GetUser(id int64) (*User, error)
- func (db *DBM) GetUserByName(name string) (*User, error)
- func (db *DBM) GetUsers(limit int64) ([]*User, error)
- func (db *DBM) InitDatabase() error
- func (db *DBM) SaveUser(u *User) error
- type Group
- type User
Constants ¶
View Source
const (
DefaultName = "accounts"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DBM ¶
DBM is a DB manager for user accounts and groups.
func (*DBM) AddUser ¶
func (db *DBM) AddUser(username, password, email, first, last, data, tokens string, cost int) (*User, error)
AddUser creates a new User. This may fail.
func (*DBM) ConnectionString ¶
func (*DBM) DatabaseExists ¶
DatabaseExists checks for the existence of the actual database.
func (*DBM) DeleteUserByName ¶
DeleteUserByName for when that's needed.
func (*DBM) GetUserByName ¶
GetUserByName for when you don't have an id.
func (*DBM) InitDatabase ¶
InitDatabase creates the tables, functions and triggers required for the full account system.
type Group ¶
type Group struct { // ID of group in the database. ID int64 // Name of group. Name string // Permissions which can be set in this group. Permissions []string }
Group structures contain the ID, name and a list of possible permissions.
func (*Group) RemovePermission ¶
RemovePermission from group.
type User ¶
type User struct { // ID of user in the database. ID int64 // Username to log in with. Usermame string // Password for user account. Password string // Salt for the password. Salt string // Email to verify account or reset password. Email string // Created timestamp. Created time.Time // Locked accounts can't log in. Locked bool // Sites the user is a member of. Sites []string // First name of user (optional). First string // Last name of user (optional). Last string // Data for the account. JSON field for all the customising you need. Data string // Tokens is meant to store any authentication tokens required for external sites. Tokens string }
User account structure holds basic login and personal information.
func (*User) CheckPassword ¶
CheckPassword against the account's hash.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.