radblock / plans

this repo has issues turned on
ISC License
0 stars 0 forks source link

email verification #12

Open amonks opened 8 years ago

amonks commented 8 years ago

users

We have an s3 bucket called radblock-users.

a user is a json file in that bucket that looks like this:

{
  "email": "jdoe@saic.edu",
  "password_hash": "something",
  "password_salt": "something",
  "stripe_stuff": "whatever",
  "state": "pending",
  "pending_gif": "key_of_gif_in_radblock-pending-gifs",
  "code": "email-authorization-code"
}

even though it's a json file, instead of being called "whatever.json", the filename is the user's email address so we can look it up easily.

I should probably use a proper json store like dynamodb for this, but I won't, 'cuz fuck the system.

possible user states

Since you can only upload a gif every 24 hours anyway, new and old users both use the same upload screen, there's no cookies or logged-in-ness and no distinction between "sign in" and "sign up"; the only action is "upload a gif" (or more accurately, "try to upload a gif")

new user process

I'll describe what happens for a new user since it's the most complicated (and since it relates to email verification)

  1. user new or old types their email, password, and gif, and credit card deets into the browser, and they're submitted to stripe for card verification, which then submits them and a token to the http://github.com/radblock/signatory lambda function
  2. the signatory looks for the user in the bucket, doesn't find it, generates an email authorization code, and creates a new user with the state "pending". It approves the s3 upload but to a special bucket called radblock-pending-gifs.
  3. the signatory emails the user with a link like "radblock.xyz/?user={email}&code={code}"
  4. the user clicks the link, and triggers a new lambda function called "email-verifier". It checks the code. If it's correct, it does the following:
    • charges the user's card using the token from step 1
    • changes the user's state to "rate-limited"
    • creates a new object called the user's email address in a bucket called "radblock-rate-limit" which expires in 24 hours.
    • moves their gif from "radblock-pending-gifs" into "gifs.radblock.xyz"
amonks commented 8 years ago

behind the scenes