Skip to content

Commit a5b2d75

Browse files
authored
fix: omit explicit transaction in ConfirmLoginSession and add tracing (#3886)
1 parent 68aa167 commit a5b2d75

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

persistence/sql/persister_consent.go

+9-16
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,7 @@ func (p *Persister) ConfirmLoginSession(ctx context.Context, loginSession *flow.
388388
return p.mySQLConfirmLoginSession(ctx, loginSession)
389389
}
390390

391-
err = p.Connection(ctx).Transaction(func(tx *pop.Connection) error {
392-
res, err := tx.TX.NamedExec(`
391+
res, err := p.Connection(ctx).Store.NamedExecContext(ctx, `
393392
INSERT INTO hydra_oauth2_authentication_session (id, nid, authenticated_at, subject, remember, identity_provider_session_id)
394393
VALUES (:id, :nid, :authenticated_at, :subject, :remember, :identity_provider_session_id)
395394
ON CONFLICT(id) DO
@@ -400,22 +399,16 @@ UPDATE SET
400399
identity_provider_session_id = :identity_provider_session_id
401400
WHERE hydra_oauth2_authentication_session.id = :id AND hydra_oauth2_authentication_session.nid = :nid
402401
`, loginSession)
403-
if err != nil {
404-
return sqlcon.HandleError(err)
405-
}
406-
n, err := res.RowsAffected()
407-
if err != nil {
408-
return sqlcon.HandleError(err)
409-
}
410-
if n == 0 {
411-
return errorsx.WithStack(x.ErrNotFound)
412-
}
413-
return nil
414-
})
415402
if err != nil {
416-
return errors.WithStack(err)
403+
return sqlcon.HandleError(err)
404+
}
405+
n, err := res.RowsAffected()
406+
if err != nil {
407+
return sqlcon.HandleError(err)
408+
}
409+
if n == 0 {
410+
return errorsx.WithStack(x.ErrNotFound)
417411
}
418-
419412
return nil
420413
}
421414

0 commit comments

Comments
 (0)