mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-01-06 00:18:50 +02:00
Merge branch 'master' into develop
This commit is contained in:
commit
a7bb599cd0
@ -69,6 +69,8 @@
|
||||
|
||||
- Fixed collection index column sort normalization in the Admin UI ([#2681](https://github.com/pocketbase/pocketbase/pull/2681); thanks @SimonLoir).
|
||||
|
||||
- Removed unnecessary admins count in `apis.RequireAdminAuthOnlyIfAny()` middleware ([#2726](https://github.com/pocketbase/pocketbase/pull/2726); thanks @svekko).
|
||||
|
||||
|
||||
## v0.16.5
|
||||
|
||||
|
@ -129,14 +129,17 @@ func RequireAdminAuth() echo.MiddlewareFunc {
|
||||
func RequireAdminAuthOnlyIfAny(app core.App) echo.MiddlewareFunc {
|
||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||
return func(c echo.Context) error {
|
||||
admin, _ := c.Get(ContextAdminKey).(*models.Admin)
|
||||
if admin != nil {
|
||||
return next(c)
|
||||
}
|
||||
|
||||
totalAdmins, err := app.Dao().TotalAdmins()
|
||||
if err != nil {
|
||||
return NewBadRequestError("Failed to fetch admins info.", err)
|
||||
}
|
||||
|
||||
admin, _ := c.Get(ContextAdminKey).(*models.Admin)
|
||||
|
||||
if admin != nil || totalAdmins == 0 {
|
||||
if totalAdmins == 0 {
|
||||
return next(c)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user