Add route for accepting an invitation with an existing account
[?]
Jul 24, 2015, 1:43 AM
MB5SHULBN3WP7TGUWZDP6BRGP423FTYKF67T5IF5YHHLNXKQ5REACDependencies
- [2]
LCBJULKEFix swapped default and key in QConfig. - [3]
M3KUPGZKAdd invitation email template. - [4]
A6HKMINBAttempting to improve JSON handling. - [5]
QMRKFEPGRefactor QDB to use a free monad algebra instead. - [6]
2XQD6KKKAdd invitation logic and clean up DBProg error handling. - [7]
PBD7LZYQPostgres & auth are beginning to function. - [8]
45QJYWN3Fixing up the README. Still struggling with the ending. - [9]
Z7KS5XHHVery WIP. Wow. - [10]
EZQG2APBUpdate task list. - [*]
64C6AWH6Rename Ananke -> Quixotic, project reboot. - [*]
BROSTG5KBeginning of modularization of server. - [*]
I2KHGVD4Require project permissions for access to most data. - [*]
BXGLKYRXAdded primitive user registration handler. - [*]
ADMKQQGCInitial empty Snap project. - [*]
O5FVTOM6Undo JSON silliness, enable a couple more routes.
Change contents
- edit in TASKS.md at line 26
* Invite* When a new participant is invited to the project, allow them to create an account.- user creates account ands provides initial payout address- inviting user asked to sign a txn that transfers a specific amount of btc from theircurrent payout address to the invitee's payout address as confirmation ofthe invitation + script - edit in TASKS.md at line 29
- edit in TASKS.md at line 88
* Invite* When a new participant is invited to the project, allow them to create an account.- inviting user asked to sign a txn that transfers a specific amount of btc from theircurrent payout address to the invitee's payout address as confirmation ofthe invitation + script -- is this actually worth it? - replacement in lib/Aftok/Database.hs at line 116
acceptInvitation :: UserId -> InvitationCode -> C.UTCTime -> DBProg ()acceptInvitation uid ic t = doacceptInvitation :: UserId -> C.UTCTime -> InvitationCode-> DBProg ()acceptInvitation uid t ic = do - edit in server/Aftok/Snaplet/Users.hs at line 5
, acceptInvitationHandler - edit in server/Aftok/Snaplet/Users.hs at line 12
import Data.Text as T - replacement in server/Aftok/Snaplet/Users.hs at line 57
void $ traverse (\c -> acceptInvitation userId c t) (userData ^. invitationCodes)void $ traverse (acceptInvitation userId t) (userData ^. invitationCodes) - edit in server/Aftok/Snaplet/Users.hs at line 61[3.11344]
acceptInvitationHandler :: Handler App App ()acceptInvitationHandler = douid <- requireUserIdt <- liftIO C.getCurrentTimeparams <- getParamsinvCodes <- maybe(snapError 400 "invCode parameter is required")(pure . traverse (parseInvCode . decodeUtf8))(lookup "invCode" params)either(\e -> snapError 400 $ "Invitation code was rejected as invalid: " <> T.pack e)(\cx -> void . snapEval $ traverse (acceptInvitation uid t) cx)invCodes - edit in server/Main.hs at line 40[17.2397][3.12580]
acceptInviteRoute = void $ method POST acceptInvitationHandler - edit in server/Main.hs at line 55[17.2968][3.12972]
, ("accept_invitation", acceptInviteRoute) - replacement in server/templates/invitation_email.st at line 3
A friend of yours ($from_email$) has invited you to join the "$project_name$" project at http://aftok.com. Here's what you need to do to accept their invitation. At present, there's no user interface for the service other than bare HTTP requests with a JSON payload. A script has been provided below that you can edit to include your own information. You'll need to replace the following three tokens:A friend of yours ($from_email$) has invited you to join the "$project_name$"project at http://aftok.com. Here's what you need to do to accept theirinvitation. At present, there's no user interface for the service other thanbare HTTP requests with a JSON payload. A couple of scripts have been providedbelow that you can edit to include your own information.If you don't have an aftok.com account:If you do not yet have an account on aftok.com, you can create a new account andaccept your invitation in one step. If you already have an aftok.com account thatyou want to use, then then skip to the "For an existing account" section below.To create a new account and accept the invitation, you'll need to replacethe following three tokens in the curl command below: - replacement in server/templates/invitation_email.st at line 20
BTC_ADDR -- the bitcoin address that you want payouts to be initially sent to. You'll be able to change this later, but because changes of payout addresses are validated by checking transactions on the blockchain, it's important that this be a usable address that you control.BTC_ADDR -- the bitcoin address that you want payouts to be initially sent to.You'll be able to change this later, but because changes of payout addressesare validated by checking transactions on the blockchain, it's important thatthis be a usable address that you control. - replacement in server/templates/invitation_email.st at line 25
Substitute your own values for the tokens in the script below, then run it! Also, if you'd prefer that a different email address be associated with your account, change that as well.Substitute your own values for the tokens in the script below, then run it!Also, if you'd prefer that a different email address be associated with youraccount, change that as well. - edit in server/templates/invitation_email.st at line 30[3.1915]
For an existing account:To accept the invitation using your current aftok.com account, you'll simply need toreplace the <USER> token in the command below with your username:curl -k -v -u <USER> -d '' https://aftok.com/accept_invitation?invCode=$inv_code$