Add admin user, and an option to add a user admin on startup
This commit is contained in:
@@ -5,12 +5,24 @@ import (
|
||||
|
||||
"git.artlef.fr/bibliomane/internal/appcontext"
|
||||
"git.artlef.fr/bibliomane/internal/dto"
|
||||
"git.artlef.fr/bibliomane/internal/myvalidator"
|
||||
)
|
||||
|
||||
func GetAppInfo(ac appcontext.AppContext) {
|
||||
admin := false
|
||||
_, userIsInContext := ac.C.Get("user")
|
||||
if userIsInContext {
|
||||
user, err := ac.GetAuthenticatedUser()
|
||||
if err != nil {
|
||||
myvalidator.ReturnErrorsAsJsonResponse(&ac, err)
|
||||
return
|
||||
}
|
||||
admin = user.Admin
|
||||
}
|
||||
ac.C.JSON(http.StatusOK, dto.AppInfo{
|
||||
RegistrationDisabled: ac.Config.DisableRegistration,
|
||||
DemoMode: ac.Config.DemoMode,
|
||||
DemoUsername: ac.Config.DemoUsername,
|
||||
Admin: admin,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user