- Generate random verification code
XXXXXX
- Check that code does not already exist in database. If it does exist, GOTO (1), else GOTO (3).
- Send email to
email_address
containing link to/verify/XXXXXX
- Store in database the row
creation_date: time.Now(), email: email_address, code: XXXXXX, is_verified: false
- Response JSON:
{"Address": "email_address", "Success": true, "Note": ""}
- Check
email_address
in database andverified = true
- Response JSON:
{"Address": "email_address", "Success": true, "Note": ""}
- Look up
code = XXXXXX
in database. IfXXXXXX
exists, GOTO 2, else GOTO 3. - If
is_verified: false
GOTO 4, else GOTO 5 - Response JSON:
{"Code": "XXXXXX", "Success": false, "Note": "no such verification code"}
- Mark
is_verified
astrue
in database, GOTO 6 - Response JSON:
{"Code": "XXXXXX", "Success": false, "Note": "signup already verified"}
- Response JSON:
{"Code": "XXXXXX", "Success": true, "Note": ""}
I found this incredibly useful in helping me design testable code using Google App Engine: https://www.compoundtheory.com/testing-go-http-handlers-in-google-app-engine-with-mux-and-higher-order-functions/