mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-03-20 14:31:09 +02:00
[#5800] skip default loadAuthToken middleware if e.Auth is already set
This commit is contained in:
parent
47354f5aa9
commit
4f67dba6cb
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
- Fixed JSVM types errors ([#5797](https://github.com/pocketbase/pocketbase/issues/5797)).
|
- Fixed JSVM types errors ([#5797](https://github.com/pocketbase/pocketbase/issues/5797)).
|
||||||
|
|
||||||
|
- Skip default `loadAuthToken` middleware if `e.Auth` is already loaded ([#5800](https://github.com/pocketbase/pocketbase/discussions/5800)).
|
||||||
|
|
||||||
|
|
||||||
## v0.23.0-rc10
|
## v0.23.0-rc10
|
||||||
|
|
||||||
|
@ -196,7 +196,9 @@ func RequireSameCollectionContextAuth(collectionPathParam string) *hook.Handler[
|
|||||||
|
|
||||||
// loadAuthToken attempts to load the auth context based on the "Authorization: TOKEN" header value.
|
// loadAuthToken attempts to load the auth context based on the "Authorization: TOKEN" header value.
|
||||||
//
|
//
|
||||||
// This middleware does nothing in case of missing, invalid or expired token.
|
// This middleware does nothing in case of:
|
||||||
|
// - missing, invalid or expired token
|
||||||
|
// - e.Auth is already loaded by another middleware
|
||||||
//
|
//
|
||||||
// This middleware is registered by default for all routes.
|
// This middleware is registered by default for all routes.
|
||||||
//
|
//
|
||||||
@ -207,6 +209,11 @@ func loadAuthToken() *hook.Handler[*core.RequestEvent] {
|
|||||||
Id: DefaultLoadAuthTokenMiddlewareId,
|
Id: DefaultLoadAuthTokenMiddlewareId,
|
||||||
Priority: DefaultLoadAuthTokenMiddlewarePriority,
|
Priority: DefaultLoadAuthTokenMiddlewarePriority,
|
||||||
Func: func(e *core.RequestEvent) error {
|
Func: func(e *core.RequestEvent) error {
|
||||||
|
// already loaded by another middleware
|
||||||
|
if e.Auth != nil {
|
||||||
|
return e.Next()
|
||||||
|
}
|
||||||
|
|
||||||
token := getAuthTokenFromRequest(e)
|
token := getAuthTokenFromRequest(e)
|
||||||
if token == "" {
|
if token == "" {
|
||||||
return e.Next()
|
return e.Next()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user