mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-02-09 12:14:03 +02:00
added ProviderName and ProviderClient fields to core.RecordAuthWithOAuth2Event
This commit is contained in:
parent
f024de3cc4
commit
3a5d3d521f
@ -28,7 +28,12 @@
|
||||
|
||||
- Added `migrate history-sync` command to clean `_migrations` history table from deleted migration files references.
|
||||
|
||||
- Added `core.RecordAuthWithOAuth2Event.IsNewRecord` bool field to indicate whether the OAuth2 action created a new auth record.
|
||||
- Added new fields to the `core.RecordAuthWithOAuth2Event` struct:
|
||||
```
|
||||
IsNewRecord bool, // boolean field indicating whether the OAuth2 action created a new auth record
|
||||
ProviderName string, // the name of the OAuth2 provider (eg. "google")
|
||||
ProviderClient auth.Provider, // the loaded Provider client instance
|
||||
```
|
||||
|
||||
- **!** Renamed `daos.GetTableColumns()` to `daos.TableColumns()` for consistency with the other Dao table related helpers.
|
||||
|
||||
|
@ -180,6 +180,7 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error {
|
||||
event := new(core.RecordAuthWithOAuth2Event)
|
||||
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 {
|
||||
@ -223,6 +224,7 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error {
|
||||
return func(data *forms.RecordOAuth2LoginData) error {
|
||||
event.Record = data.Record
|
||||
event.OAuth2User = data.OAuth2User
|
||||
event.ProviderClient = data.ProviderClient
|
||||
|
||||
return api.app.OnRecordBeforeAuthWithOAuth2Request().Trigger(event, func(e *core.RecordAuthWithOAuth2Event) error {
|
||||
data.Record = e.Record
|
||||
|
@ -205,10 +205,12 @@ type RecordAuthWithPasswordEvent struct {
|
||||
type RecordAuthWithOAuth2Event struct {
|
||||
BaseCollectionEvent
|
||||
|
||||
HttpContext echo.Context
|
||||
Record *models.Record
|
||||
OAuth2User *auth.AuthUser
|
||||
IsNewRecord bool
|
||||
HttpContext echo.Context
|
||||
ProviderName string
|
||||
ProviderClient auth.Provider
|
||||
Record *models.Record
|
||||
OAuth2User *auth.AuthUser
|
||||
IsNewRecord bool
|
||||
}
|
||||
|
||||
type RecordAuthRefreshEvent struct {
|
||||
|
@ -18,9 +18,10 @@ import (
|
||||
|
||||
// RecordOAuth2LoginData defines the OA
|
||||
type RecordOAuth2LoginData struct {
|
||||
ExternalAuth *models.ExternalAuth
|
||||
Record *models.Record
|
||||
OAuth2User *auth.AuthUser
|
||||
ExternalAuth *models.ExternalAuth
|
||||
Record *models.Record
|
||||
OAuth2User *auth.AuthUser
|
||||
ProviderClient auth.Provider
|
||||
}
|
||||
|
||||
// BeforeOAuth2RecordCreateFunc defines a callback function that will
|
||||
@ -176,9 +177,10 @@ func (form *RecordOAuth2Login) Submit(
|
||||
}
|
||||
|
||||
interceptorData := &RecordOAuth2LoginData{
|
||||
ExternalAuth: rel,
|
||||
Record: authRecord,
|
||||
OAuth2User: authUser,
|
||||
ExternalAuth: rel,
|
||||
Record: authRecord,
|
||||
OAuth2User: authUser,
|
||||
ProviderClient: provider,
|
||||
}
|
||||
|
||||
interceptorsErr := runInterceptors(interceptorData, func(newData *RecordOAuth2LoginData) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user