mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-09-10 23:58:25 +02:00
[BUG] First user created through reverse proxy should be admin
- Currently users created through the reverse proxy aren't created trough the normal route of `createAndHandleCreatedUser` as this does a lot of other routines which aren't necessary for the reverse proxy auth, however one routine is important to have: the first created user should be an admin. This patch adds that code - Adds unit test. - Resolves #4437
This commit is contained in:
parent
3b8ac4388a
commit
0692cc2cc1
2 changed files with 72 additions and 0 deletions
|
@ -164,6 +164,11 @@ func (r *ReverseProxy) newUser(req *http.Request) *user_model.User {
|
|||
IsActive: optional.Some(true),
|
||||
}
|
||||
|
||||
// The first user created should be an admin.
|
||||
if user_model.CountUsers(req.Context(), nil) == 0 {
|
||||
user.IsAdmin = true
|
||||
}
|
||||
|
||||
if err := user_model.CreateUser(req.Context(), user, &overwriteDefault); err != nil {
|
||||
// FIXME: should I create a system notice?
|
||||
log.Error("CreateUser: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue