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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -206,6 +206,8 @@ type RecordAuthWithOAuth2Event struct {
 | 
			
		|||
	BaseCollectionEvent
 | 
			
		||||
 | 
			
		||||
	HttpContext    echo.Context
 | 
			
		||||
	ProviderName   string
 | 
			
		||||
	ProviderClient auth.Provider
 | 
			
		||||
	Record         *models.Record
 | 
			
		||||
	OAuth2User     *auth.AuthUser
 | 
			
		||||
	IsNewRecord    bool
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ type RecordOAuth2LoginData struct {
 | 
			
		|||
	ExternalAuth   *models.ExternalAuth
 | 
			
		||||
	Record         *models.Record
 | 
			
		||||
	OAuth2User     *auth.AuthUser
 | 
			
		||||
	ProviderClient auth.Provider
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BeforeOAuth2RecordCreateFunc defines a callback function that will
 | 
			
		||||
| 
						 | 
				
			
			@ -179,6 +180,7 @@ func (form *RecordOAuth2Login) Submit(
 | 
			
		|||
		ExternalAuth:   rel,
 | 
			
		||||
		Record:         authRecord,
 | 
			
		||||
		OAuth2User:     authUser,
 | 
			
		||||
		ProviderClient: provider,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	interceptorsErr := runInterceptors(interceptorData, func(newData *RecordOAuth2LoginData) error {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue