@@ -14,6 +14,7 @@ import (
1414 jwt "github.com/golang-jwt/jwt"
1515 "github.com/netlify/gotrue/api/provider"
1616 "github.com/netlify/gotrue/conf"
17+ "github.com/netlify/gotrue/logger"
1718 "github.com/netlify/gotrue/models"
1819 "github.com/netlify/gotrue/storage"
1920 "github.com/netlify/gotrue/utilities"
@@ -60,7 +61,7 @@ func (a *API) ExternalProviderRedirect(w http.ResponseWriter, r *http.Request) e
6061 }
6162
6263 redirectURL := a .getRedirectURLOrReferrer (r , query .Get ("redirect_to" ))
63- log := getLogEntry (r )
64+ log := logger . GetLogEntry (r )
6465 log .WithField ("provider" , providerType ).Info ("Redirecting to external provider" )
6566
6667 token := jwt .NewWithClaims (jwt .SigningMethodHS256 , ExternalProviderClaims {
@@ -140,7 +141,7 @@ func (a *API) internalExternalProviderCallback(w http.ResponseWriter, r *http.Re
140141 var terr error
141142 inviteToken := getInviteToken (ctx )
142143 if inviteToken != "" {
143- if user , terr = a .processInvite (ctx , tx , userData , instanceID , inviteToken , providerType ); terr != nil {
144+ if user , terr = a .processInvite (r , ctx , tx , userData , instanceID , inviteToken , providerType ); terr != nil {
144145 return terr
145146 }
146147 } else {
@@ -255,7 +256,7 @@ func (a *API) internalExternalProviderCallback(w http.ResponseWriter, r *http.Re
255256 return nil
256257 }
257258
258- if terr := models .NewAuditLogEntry (tx , instanceID , user , models .UserSignedUpAction , "" , map [string ]interface {}{
259+ if terr := models .NewAuditLogEntry (r , tx , instanceID , user , models .UserSignedUpAction , "" , map [string ]interface {}{
259260 "provider" : providerType ,
260261 }); terr != nil {
261262 return terr
@@ -269,7 +270,7 @@ func (a *API) internalExternalProviderCallback(w http.ResponseWriter, r *http.Re
269270 return internalServerError ("Error updating user" ).WithInternalError (terr )
270271 }
271272 } else {
272- if terr := models .NewAuditLogEntry (tx , instanceID , user , models .LoginAction , "" , map [string ]interface {}{
273+ if terr := models .NewAuditLogEntry (r , tx , instanceID , user , models .LoginAction , "" , map [string ]interface {}{
273274 "provider" : providerType ,
274275 }); terr != nil {
275276 return terr
@@ -311,7 +312,7 @@ func (a *API) internalExternalProviderCallback(w http.ResponseWriter, r *http.Re
311312 return nil
312313}
313314
314- func (a * API ) processInvite (ctx context.Context , tx * storage.Connection , userData * provider.UserProvidedData , instanceID uuid.UUID , inviteToken , providerType string ) (* models.User , error ) {
315+ func (a * API ) processInvite (r * http. Request , ctx context.Context , tx * storage.Connection , userData * provider.UserProvidedData , instanceID uuid.UUID , inviteToken , providerType string ) (* models.User , error ) {
315316 config := a .getConfig (ctx )
316317 user , err := models .FindUserByConfirmationToken (tx , inviteToken )
317318 if err != nil {
@@ -357,7 +358,7 @@ func (a *API) processInvite(ctx context.Context, tx *storage.Connection, userDat
357358 return nil , internalServerError ("Database error updating user" ).WithInternalError (err )
358359 }
359360
360- if err := models .NewAuditLogEntry (tx , instanceID , user , models .InviteAcceptedAction , "" , map [string ]interface {}{
361+ if err := models .NewAuditLogEntry (r , tx , instanceID , user , models .InviteAcceptedAction , "" , map [string ]interface {}{
361362 "provider" : providerType ,
362363 }); err != nil {
363364 return nil , err
@@ -443,7 +444,7 @@ func (a *API) Provider(ctx context.Context, name string, scopes string, query *u
443444
444445func (a * API ) redirectErrors (handler apiHandler , w http.ResponseWriter , r * http.Request ) {
445446 ctx := r .Context ()
446- log := getLogEntry (r )
447+ log := logger . GetLogEntry (r )
447448 errorID := getRequestID (ctx )
448449 err := handler (w , r )
449450 if err != nil {
0 commit comments