29 lines
673 B
Go
29 lines
673 B
Go
package routes
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"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,
|
|
})
|
|
}
|