_,err=s.pool.Exec(r.Context(),`UPDATE `+s.accountSessionTable()+` SET csrf_hash=$2 WHERE token_hash=$1 AND revoked_at IS NULL AND expires_at>now()`,digest([]byte(cookie.Value)),digest([]byte(token)))
_,err=s.pool.Exec(r.Context(),`UPDATE onboarding_web_session SET csrf_hash=$2 WHERE token_hash=$1 AND issuer=$3 AND subject=$4 AND revoked_at IS NULL AND expires_at>now()`,digest([]byte(c.Value)),digest([]byte(token)),p.Issuer,p.Subject)
err=s.pool.QueryRow(r.Context(),`SELECT EXISTS(SELECT 1 FROM `+table+` WHERE token_hash=$1 AND revoked_at IS NULL AND expires_at>now())`,digest([]byte(c.Value))).Scan(&live)
iferr!=nil{
returnnil,err
}
iflive{
varvalidbool
err=s.pool.QueryRow(r.Context(),`SELECT EXISTS(SELECT 1 FROM `+table+` WHERE token_hash=$1 AND csrf_hash=$2)`,digest([]byte(c.Value)),digest([]byte(r.Header.Get("X-CSRF-Token")))).Scan(&valid)