mirror of
https://github.com/pushbits/server.git
synced 2025-05-24 14:26:35 +02:00
Prevent deletion of last admin account
This commit is contained in:
parent
470a3f819d
commit
c0ac5c3d16
2 changed files with 20 additions and 0 deletions
|
@ -56,3 +56,12 @@ func (d *Database) GetApplications(user *model.User) ([]model.Application, error
|
|||
|
||||
return applications, err
|
||||
}
|
||||
|
||||
// AdminUserCount returns the number of admins or an error.
|
||||
func (d *Database) AdminUserCount() (int64, error) {
|
||||
var users []model.User
|
||||
|
||||
query := d.gormdb.Where("is_admin = ?", true).Find(&users)
|
||||
|
||||
return query.RowsAffected, query.Error
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue