Documentation ¶
Index ¶
- Constants
- func GenString(size int) string
- type DBM
- func (db *DBM) AddProfile(id, user int64, domain, data string) *Profile
- 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) InitDatabase() error
- func (db *DBM) SaveUser(u *User) error
- type Group
- type Profile
- type User
Constants ¶
const (
DefaultName = "accounts"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DBM ¶
DBM is a DB manager for user accounts and groups.
func (*DBM) AddProfile ¶
AddProfile creates a new profile.
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 Profile ¶
type Profile struct { // ID of profile in the database. ID int64 // User ID this profile belongs to. User int64 // Domain this profile is for. This may be an actual Internet // domain or the display name for a site/business. Domain string // Groups the user belongs to on this site, with permissions. Groups map[string]string // Data for the site. Usually a custom JSON structure. Data string }
Profile for a site or business. One or more of these exist per user account.
func (*Profile) RemoveGroup ¶
RemoveGroup if it exists in the profile.
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 // Profiles for specific sites. Profiles []*Profile // 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.