better render performance and code cleanup
This commit is contained in:
parent
3cd460318a
commit
fb41dd75c4
3 changed files with 28 additions and 27 deletions
10
userdb.go
10
userdb.go
|
|
@ -56,7 +56,7 @@ func NewBoltStore(file string) (*BoltStore, error) {
|
|||
return nil, err
|
||||
}
|
||||
bs := &BoltStore{NewGOB(), db}
|
||||
bs.UnlockUser("admin")
|
||||
bs.UnlockUser(defUser)
|
||||
return bs, nil
|
||||
}
|
||||
|
||||
|
|
@ -217,8 +217,8 @@ func (bs *BoltStore) UpdateUserPassword(username, password string) error {
|
|||
}
|
||||
|
||||
func (bs *BoltStore) AdminUpdateUser(username, password string, admin bool) error {
|
||||
if username == "admin" && !admin {
|
||||
return errors.New("user 'admin' cannot lose admin privileges")
|
||||
if username == defUser && !admin {
|
||||
return errors.New("user '" + defUser + "' cannot lose admin privileges")
|
||||
}
|
||||
return bs.db.Update(func(tx *bolt.Tx) error {
|
||||
us, err := bs.GetUser(username)
|
||||
|
|
@ -242,8 +242,8 @@ func (bs *BoltStore) AdminUpdateUser(username, password string, admin bool) erro
|
|||
}
|
||||
|
||||
func (bs *BoltStore) DeleteUser(username string) error {
|
||||
if username == "admin" {
|
||||
return errors.New("user 'admin' cannot be deleted")
|
||||
if username == defUser {
|
||||
return errors.New("user '" + defUser + "' cannot be deleted")
|
||||
}
|
||||
return bs.db.Update(func(tx *bolt.Tx) error {
|
||||
if bs.UserExists(username) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue