Review fixes: no duplicate invoices, safer logins and redirects, one charge per click
Invoicing: the invoice request is marked before it goes to Billingo; a retry after a lost answer looks the invoice up under the invoice's own partner instead of issuing a second one. An invoice issued but never e-mailed counts as issued (downloadable). A Hungarian company with only an EU VAT number is invoiced without a domestic tax number, the EU number in the comment. Security: the login redirect takes only plain local paths (no backslash); the waitlist rate limit and share visits use X-Real-IP, which Caddy sets from Cloudflare's address, not the spoofable first X-Forwarded-For entry; a Google/Apple sign-in to an unconfirmed password account removes its password and sessions; a person's birth data can no longer be published through a share. Credits and jobs: analysis requests are serialized per user, so a double click queues and pays once; a forecast analysis also fixes a person's birth data; admins can restart stuck tarot readings; a worker forgets an attempt an admin restarted, so a stop does not requeue it; two people accepting one comparison invite at once get one comparison. Expired invitations are no longer accepted by e-mail, and unsubscribing revokes the invitation's promo codes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -389,6 +389,23 @@ async fn social_login(
|
||||
sqlx::query_as("SELECT id FROM users WHERE email = $1").bind(&email).fetch_optional(&mut *tx).await?;
|
||||
let (id, created) = match existing {
|
||||
Some((id,)) => {
|
||||
// An account whose address was never confirmed may have
|
||||
// been made by someone else with this address: its
|
||||
// password and sessions go, the provider has proven who
|
||||
// owns the address.
|
||||
let unverified: bool =
|
||||
sqlx::query_scalar("SELECT email_verified_at IS NULL FROM users WHERE id = $1 FOR UPDATE")
|
||||
.bind(id)
|
||||
.fetch_one(&mut *tx)
|
||||
.await?;
|
||||
if unverified {
|
||||
sqlx::query("DELETE FROM auth_identities WHERE user_id = $1 AND provider = 'password'")
|
||||
.bind(id)
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
sqlx::query("DELETE FROM sessions WHERE user_id = $1").bind(id).execute(&mut *tx).await?;
|
||||
tracing::warn!(user = %id, provider, "unconfirmed password account taken over by its address's owner");
|
||||
}
|
||||
// The provider has verified the address, so it counts as verified here too.
|
||||
sqlx::query(
|
||||
"UPDATE users SET email_verified_at = COALESCE(email_verified_at, now()) WHERE id = $1",
|
||||
|
||||
Reference in New Issue
Block a user