added a flag indicating OAuth2 auth record creation
This commit is contained in:
		
							parent
							
								
									be0ee7f66c
								
							
						
					
					
						commit
						e5a22b8bd8
					
				| 
						 | 
					@ -26,6 +26,8 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Added option to explicitly set the record id from the Admin UI ([#2118](https://github.com/pocketbase/pocketbase/issues/2118)).
 | 
					- Added option to explicitly set the record id from the Admin UI ([#2118](https://github.com/pocketbase/pocketbase/issues/2118)).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- Added `core.RecordAuthWithOAuth2Event.IsNewRecord` bool field to indicate whether the OAuth2 action created a new auth record.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- **!** Renamed `daos.GetTableColumns()` to `daos.TableColumns()` for consistency with the other Dao table related helpers.
 | 
					- **!** Renamed `daos.GetTableColumns()` to `daos.TableColumns()` for consistency with the other Dao table related helpers.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- **!** Renamed `daos.GetTableInfo()` to `daos.TableInfo()` for consistency with the other Dao table related helpers.
 | 
					- **!** Renamed `daos.GetTableInfo()` to `daos.TableInfo()` for consistency with the other Dao table related helpers.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -177,10 +177,16 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error {
 | 
				
			||||||
		return NewBadRequestError("An error occurred while loading the submitted data.", readErr)
 | 
							return NewBadRequestError("An error occurred while loading the submitted data.", readErr)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						event := new(core.RecordAuthWithOAuth2Event)
 | 
				
			||||||
 | 
						event.HttpContext = c
 | 
				
			||||||
 | 
						event.Collection = collection
 | 
				
			||||||
 | 
						event.IsNewRecord = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	form.SetBeforeNewRecordCreateFunc(func(createForm *forms.RecordUpsert, authRecord *models.Record, authUser *auth.AuthUser) error {
 | 
						form.SetBeforeNewRecordCreateFunc(func(createForm *forms.RecordUpsert, authRecord *models.Record, authUser *auth.AuthUser) error {
 | 
				
			||||||
		return createForm.DrySubmit(func(txDao *daos.Dao) error {
 | 
							return createForm.DrySubmit(func(txDao *daos.Dao) error {
 | 
				
			||||||
			requestData := RequestData(c)
 | 
								requestData := RequestData(c)
 | 
				
			||||||
			requestData.Data = form.CreateData
 | 
								requestData.Data = form.CreateData
 | 
				
			||||||
 | 
								event.IsNewRecord = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			createRuleFunc := func(q *dbx.SelectQuery) error {
 | 
								createRuleFunc := func(q *dbx.SelectQuery) error {
 | 
				
			||||||
				admin, _ := c.Get(ContextAdminKey).(*models.Admin)
 | 
									admin, _ := c.Get(ContextAdminKey).(*models.Admin)
 | 
				
			||||||
| 
						 | 
					@ -213,10 +219,6 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error {
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	event := new(core.RecordAuthWithOAuth2Event)
 | 
					 | 
				
			||||||
	event.HttpContext = c
 | 
					 | 
				
			||||||
	event.Collection = collection
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	_, _, submitErr := form.Submit(func(next forms.InterceptorNextFunc[*forms.RecordOAuth2LoginData]) forms.InterceptorNextFunc[*forms.RecordOAuth2LoginData] {
 | 
						_, _, submitErr := form.Submit(func(next forms.InterceptorNextFunc[*forms.RecordOAuth2LoginData]) forms.InterceptorNextFunc[*forms.RecordOAuth2LoginData] {
 | 
				
			||||||
		return func(data *forms.RecordOAuth2LoginData) error {
 | 
							return func(data *forms.RecordOAuth2LoginData) error {
 | 
				
			||||||
			event.Record = data.Record
 | 
								event.Record = data.Record
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -208,6 +208,7 @@ type RecordAuthWithOAuth2Event struct {
 | 
				
			||||||
	HttpContext echo.Context
 | 
						HttpContext echo.Context
 | 
				
			||||||
	Record      *models.Record
 | 
						Record      *models.Record
 | 
				
			||||||
	OAuth2User  *auth.AuthUser
 | 
						OAuth2User  *auth.AuthUser
 | 
				
			||||||
 | 
						IsNewRecord bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type RecordAuthRefreshEvent struct {
 | 
					type RecordAuthRefreshEvent struct {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue