Skip to content

Commit

Permalink
fix: omit explicit transaction in ConfirmLoginSession and add tracing (
Browse files Browse the repository at this point in the history
  • Loading branch information
alnr authored Nov 15, 2024
1 parent 68aa167 commit a5b2d75
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions persistence/sql/persister_consent.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ func (p *Persister) ConfirmLoginSession(ctx context.Context, loginSession *flow.
return p.mySQLConfirmLoginSession(ctx, loginSession)
}

err = p.Connection(ctx).Transaction(func(tx *pop.Connection) error {
res, err := tx.TX.NamedExec(`
res, err := p.Connection(ctx).Store.NamedExecContext(ctx, `
INSERT INTO hydra_oauth2_authentication_session (id, nid, authenticated_at, subject, remember, identity_provider_session_id)
VALUES (:id, :nid, :authenticated_at, :subject, :remember, :identity_provider_session_id)
ON CONFLICT(id) DO
Expand All @@ -400,22 +399,16 @@ UPDATE SET
identity_provider_session_id = :identity_provider_session_id
WHERE hydra_oauth2_authentication_session.id = :id AND hydra_oauth2_authentication_session.nid = :nid
`, loginSession)
if err != nil {
return sqlcon.HandleError(err)
}
n, err := res.RowsAffected()
if err != nil {
return sqlcon.HandleError(err)
}
if n == 0 {
return errorsx.WithStack(x.ErrNotFound)
}
return nil
})
if err != nil {
return errors.WithStack(err)
return sqlcon.HandleError(err)
}
n, err := res.RowsAffected()
if err != nil {
return sqlcon.HandleError(err)
}
if n == 0 {
return errorsx.WithStack(x.ErrNotFound)
}

return nil
}

Expand Down

0 comments on commit a5b2d75

Please sign in to comment.