Documentation ¶
Index ¶
- Constants
- func Base6424(src string) string
- func GenString(size int) string
- func GenerateDovecotPassword(password, salt string, rounds 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) GetSitesForUser(u *User) 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 Site
- type User
Constants ¶
const (
DefaultName = "accounts"
)
Variables ¶
This section is empty.
Functions ¶
func GenerateDovecotPassword ¶ added in v0.4.0
GenerateDovecotPassword creates a Dovecot-compatible password with the SHA512-CRYPT algorithm prefix.
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) GetSitesForUser ¶ added in v0.4.0
GetSitesForUser fills the Sites field in the User struct.
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 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.
func (*User) CompareDovecotHashAndPassword ¶ added in v0.4.0
func (*User) SetDovecotPassword ¶ added in v0.4.0
SetDovecotPassword sets a Dovecot-compatible password for the user.