updated to use new hws version
This commit is contained in:
@@ -38,7 +38,9 @@ func (auth *Authenticator[T, TX]) authenticate() hws.MiddlewareFunc {
|
||||
Error: errors.Wrap(err, "auth.beginTx"),
|
||||
}
|
||||
}
|
||||
defer tx.Rollback()
|
||||
defer func() {
|
||||
_ = tx.Rollback()
|
||||
}()
|
||||
// Type assert to TX - safe because user's beginTx should return their TX type
|
||||
txTyped, ok := tx.(TX)
|
||||
if !ok {
|
||||
@@ -64,7 +66,14 @@ func (auth *Authenticator[T, TX]) authenticate() hws.MiddlewareFunc {
|
||||
Msg("Failed to authenticate user")
|
||||
return r, nil
|
||||
}
|
||||
tx.Commit()
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
return nil, &hws.HWSError{
|
||||
Message: "Failed to commit transaction",
|
||||
StatusCode: http.StatusInternalServerError,
|
||||
Error: errors.Wrap(err, "tx.Commit"),
|
||||
}
|
||||
}
|
||||
authContext := setAuthenticatedModel(r.Context(), model)
|
||||
newReq := r.WithContext(authContext)
|
||||
return newReq, nil
|
||||
|
||||
Reference in New Issue
Block a user