Skip to content

Commit 4e5a8cc

Browse files
Merge pull request #234 from supertokens/go-fiber-example-issue
fix: go fiber example fix
2 parents 1e85a64 + 124281b commit 4e5a8cc

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [unreleased]
99

10+
- Fixes issue with go-fiber example, where updating accessTokenPayload from user defined endpoint doesn't reflect in the response cookies.
11+
1012
## [0.9.14] - 2022-12-26
1113

1214
- Fixes an issue in the dashboard recipe when fetching user details for passwordless users that don't have an email associated with their accounts

examples/with-fiber/main.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,23 @@ func main() {
119119

120120
// wrapper of the original implementation of verify session to match the required function signature
121121
func verifySession(options *sessmodels.VerifySessionOptions) fiber.Handler {
122-
shouldCallNext := false
123122
return func(c *fiber.Ctx) error {
123+
var errFromNextHandler error
124124
err := adaptor.HTTPHandlerFunc(session.VerifySession(options, func(rw http.ResponseWriter, r *http.Request) {
125125
c.SetUserContext(r.Context())
126-
shouldCallNext = true
126+
errFromNextHandler = c.Next()
127+
128+
if errFromNextHandler != nil {
129+
// just in case a supertokens error was returned, we call the supertokens error handler
130+
// also, if supertokens error was handled, we don't want to return it, hence updating errFromNextHandler
131+
errFromNextHandler = supertokens.ErrorHandler(errFromNextHandler, r, rw)
132+
}
127133
}))(c)
134+
128135
if err != nil {
129136
return err
130137
}
131-
if shouldCallNext {
132-
return c.Next()
133-
}
134-
return nil
138+
return errFromNextHandler
135139
}
136140
}
137141

0 commit comments

Comments
 (0)