Skip to content

Commit

Permalink
[pocketbase#4437] initialize RecordAuthWithOAuth2Event.IsNewRecord
Browse files Browse the repository at this point in the history
…for the `OnRecordBeforeAuthWithOAuth2Request` hook
  • Loading branch information
ganigeorgiev committed Feb 27, 2024
1 parent 39d24ba commit b845d3d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## (WIP) v0.22.1

- Initialize `RecordAuthWithOAuth2Event.IsNewRecord` for the `OnRecordBeforeAuthWithOAuth2Request` hook ([#4437](https://github.com/pocketbase/pocketbase/discussions/4437)).


## v0.22.0

- Added Planning Center OAuth2 provider ([#4393](https://github.com/pocketbase/pocketbase/pull/4393); thanks @alxjsn).
Expand Down
2 changes: 1 addition & 1 deletion apis/record_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error {
event.HttpContext = c
event.Collection = collection
event.ProviderName = form.Provider
event.IsNewRecord = false

form.SetBeforeNewRecordCreateFunc(func(createForm *forms.RecordUpsert, authRecord *models.Record, authUser *auth.AuthUser) error {
return createForm.DrySubmit(func(txDao *daos.Dao) error {
Expand Down Expand Up @@ -248,6 +247,7 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error {
event.Record = data.Record
event.OAuth2User = data.OAuth2User
event.ProviderClient = data.ProviderClient
event.IsNewRecord = data.Record == nil

return api.app.OnRecordBeforeAuthWithOAuth2Request().Trigger(event, func(e *core.RecordAuthWithOAuth2Event) error {
data.Record = e.Record
Expand Down

0 comments on commit b845d3d

Please sign in to comment.