Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
fix email confirmation / initial_matches race
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarwell committed Feb 26, 2022
1 parent 8f3bd93 commit f654125
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
14 changes: 13 additions & 1 deletion app/site/confirm.es
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,21 @@ if {isempty $expiry} {
throw error 'Your confirmation link has expired. We''ve sent you a new one. Please check your email and confirm again'
}

user = `{redis graph read 'MATCH (u:user)-[:CONFIRM]->(c:confirm {id: '''`^{echo $q_id | escape_redis}^'''})
RETURN u.username'}

# Clean up old confirmation
redis graph write 'MATCH (u:user)-[:CONFIRM]->(c:confirm {id: '''`^{echo $q_id | escape_redis}^'''})
SET u.confirmed = ''true''
SET u.confirmed = true
DELETE c'
# Start matchmaking if onboarding is finished
onboarding = `{redis graph read 'MATCH (u:user {username: '''$user'''})
RETURN u.onboarding'}
if {isempty $onboarding || ~ $onboarding 5} {
redis graph write 'MATCH (u:user {username: '''$user'''})
SET u.recompute_matches = true, u.initial_matches = true,
u.onboarding = NULL'
}

confirm_success = true
6 changes: 4 additions & 2 deletions app/site/onboarding/5.es
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ if {!~ $onboarding 5} {
post_redirect /
}

# Email confirmed? Proceed
# Email confirmed? Start matchmaking and proceed
if {~ `{redis graph read 'MATCH (u:user {username: '''$logged_user'''}) RETURN u.confirmed'} true} {
redis graph write 'MATCH (u:user {username: '''$logged_user'''}) SET u.onboarding = NULL'
redis graph write 'MATCH (u:user {username: '''$logged_user'''})
SET u.recompute_matches = true, u.initial_matches = true,
u.onboarding = NULL'
post_redirect /
}
Expand Down

0 comments on commit f654125

Please sign in to comment.