mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 17:18:59 +00:00
parent
9ba0d8b87a
commit
d922b7e504
|
@ -314,19 +314,23 @@ func CreateUser(u *User) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-set admin for user whose ID is 1.
|
// Auto-set admin for the first user.
|
||||||
if u.Id == 1 {
|
if countUsers(sess) == 1 {
|
||||||
u.IsAdmin = true
|
u.IsAdmin = true
|
||||||
u.IsActive = true
|
u.IsActive = true
|
||||||
_, err = x.Id(u.Id).UseBool().Update(u)
|
_, err = x.Id(u.Id).AllCols().Update(u)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func countUsers(e Engine) int64 {
|
||||||
|
count, _ := e.Where("type=0").Count(new(User))
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
// CountUsers returns number of users.
|
// CountUsers returns number of users.
|
||||||
func CountUsers() int64 {
|
func CountUsers() int64 {
|
||||||
count, _ := x.Where("type=0").Count(new(User))
|
return countUsers(x)
|
||||||
return count
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUsers returns given number of user objects with offset.
|
// GetUsers returns given number of user objects with offset.
|
||||||
|
|
Loading…
Reference in a new issue