{ "globals":[ ], "triggers":[ { "type":"endpoint", "meta":{ "category":"trigger", "name":"endpoint", "label":"POST /forgot-password", "x":900, "y":220, "uiId":"Hysni5EsRW", "description":"When a user submits the forgot password form ..." }, "config":{ }, "key":"", "outputIds":[ [ "HkUho9Vs0-" ] ] }, { "type":"endpoint", "meta":{ "category":"trigger", "name":"endpoint", "label":"GET /forgot-password", "x":700, "y":220, "uiId":"rJ33j54sAW", "description":"When a user visits the forgot password page ..." }, "config":{ }, "key":"", "outputIds":[ [ "B1Hho5NiA-" ] ] } ], "nodes":[ { "type":"JWTCreateNode", "meta":{ "category":"logic", "name":"jwt-create", "label":"JWT: Create", "x":1120, "y":620, "timeUnit":"Days", "description":"Create a token, which we will use for resetting the user's password. You will need to set a \"jwtSecret\" global variable, which should be a random alphanumeric string that is 16 characters long." }, "config":{ "dataTemplate":"{\n\t\"email\": \"{{userToReset.email}}\",\n \"id\": \"{{userToReset.id}}\"\n}", "dataTemplateType":"json", "secretTemplate":"{{globals.jwtSecret}}", "algorithmTemplate":"HS256", "expiresIn":86400, "issuerTemplate":"{{applicationId}}", "destinationPath":"jwt" }, "id":"HJ2i5VjA-", "outputIds":[ [ "S1x3iqVsAb" ] ] }, { "type":"EndpointReplyNode", "meta":{ "category":"output", "name":"endpoint-reply", "label":"Render Forgot Password", "x":520, "y":620, "description":"Render the forgot password page for the user." }, "config":{ "headerInfo":[ ], "cookieInfo":[ ], "replyType":"page", "replyIdPath":"", "responseCodeTemplate":"200", "bodyTemplateType":"none", "pageIdTemplate":"", "layoutIdTemplate":"" }, "id":"B1Hho5NiA-", "outputIds":[ [ "S1Nhi94s0b" ] ] }, { "type":"DebugNode", "meta":{ "category":"output", "name":"debug", "label":"Debug", "x":820, "y":820, "description":"Log the requests hitting these endpoints." }, "config":{ "message":"", "property":"" }, "id":"S1Nhi94s0b", "outputIds":[ ] }, { "type":"ValidatePayloadNode", "meta":{ "category":"logic", "name":"validate-payload", "label":"Validate Payload", "x":900, "y":320, "description":"Validate the data submitted in the post request." }, "config":{ "schema":"{\n\t\"type\": \"object\",\n \"properties\": {\n \"email\": {\n \t\"type\": \"string\",\n \"format\": \"email\"\n }\n },\n \"required\": [\"email\"],\n \"additionalProperties\": false\n}", "errorsPath":"", "toValidatePath":"data.body" }, "id":"HkUho9Vs0-", "outputIds":[ [ "HJw2o5NsRb" ], [ "BJu2j9NsC-", "SyK3ocNiCb" ] ] }, { "type":"EndpointReplyNode", "meta":{ "category":"output", "name":"endpoint-reply", "label":"Forgot Failure", "x":720, "y":620, "description":"An error occurred. Render the forgot password page with an error." }, "config":{ "headerInfo":[ ], "cookieInfo":[ ], "replyType":"page", "replyIdPath":"", "responseCodeTemplate":"401", "bodyTemplate":"{\n \"forgotPasswordFailure\": \"Not a valid email address.\"\n}", "bodyTemplateType":"json", "pageIdTemplate":"", "layoutIdTemplate":"" }, "id":"HJw2o5NsRb", "outputIds":[ [ "S1Nhi94s0b" ] ] }, { "type":"GetExperienceUserNode", "meta":{ "category":"experience", "name":"get-experience-user", "label":"Get User", "x":1080, "y":420, "description":"Asynchronously, see if we have a user with the email address that was submitted." }, "config":{ "findMethod":"emailOrId", "resultPath":"userToReset", "emailOrIdTemplate":"{{data.body.email}}" }, "id":"BJu2j9NsC-", "outputIds":[ [ "BJ52j5EsR-" ] ] }, { "type":"EndpointReplyNode", "meta":{ "category":"output", "name":"endpoint-reply", "label":"Forgot Success", "x":920, "y":620, "description":"Render the forgot password page with a success message. The state of this page is the same whether we find a user or not." }, "config":{ "headerInfo":[ ], "cookieInfo":[ ], "replyType":"page", "replyIdPath":"", "responseCodeTemplate":"301", "bodyTemplate":"{\n \"forgotPasswordSuccessMessage\": \"If a user with the email address \\\"{{data.body.email}}\\\" exists in our system, we will send an email with instructions for resetting the account password.\"\n}", "bodyTemplateType":"json", "pageIdTemplate":"", "layoutIdTemplate":"" }, "id":"SyK3ocNiCb", "outputIds":[ [ "S1Nhi94s0b" ] ] }, { "type":"ConditionalNode", "meta":{ "category":"logic", "name":"conditional", "label":"User Found?", "x":1080, "y":520, "description":"Did we find a user with that email address?" }, "config":{ "expression":"{{userToReset}}" }, "id":"BJ52j5EsR-", "outputIds":[ [ "5G7mDTQMNA" ], [ "HJ2i5VjA-" ] ] }, { "type":"StructureEmailNode", "meta":{ "category":"output", "name":"structure-email", "label":"Send Reset Email", "x":1160, "y":720, "description":"Send an email to the user with a token for resetting the account password." }, "config":{ "bodyTemplate":"\n\n \n \n \n \n \n \n
\n

Hi {{userToReset.firstName}},

\n

We received a request to reset your account password for {{data.headers.x-forwarded-proto}}://{{data.headers.host}}.

\n

Click the link below to reset your password, or copy and paste it into your browser.

\n

{{data.headers.x-forwarded-proto}}://{{data.headers.host}}/reset-password?token={{jwt}}

\n
\n \n\n", "subjectTemplate":"Request to Reset Password", "fromTemplate":"noreply@{{data.headers.host}}", "toAddresses":[ "{{userToReset.email}}" ] }, "id":"S1x3iqVsAb", "outputIds":[ [ "S1Nhi94s0b" ] ] }, { "type":"StructureEmailNode", "meta":{ "category":"output", "name":"structure-email", "label":"No User Email", "x":960, "y":720, "description":"Send an email to the address the user entered, stating that a password reset was requested but we couldn't find that user." }, "config":{ "bodyTemplate":"\n\n \n \n \n \n \n \n
\n

Hello,

\n

We received a request to reset an account password for {{data.headers.x-forwarded-proto}}://{{data.headers.host}}. However, we could not find a user in our system matching that email address.

\n

If you have an account, please sign in or reset your password using the email address that's currently associated with your account.

\n

If you do not have an account, you can ignore this email.

\n
\n \n\n", "subjectTemplate":"Request to Reset Password", "fromTemplate":"noreply@{{data.headers.host}}", "toAddresses":[ "{{data.body.email}}" ] }, "id":"5G7mDTQMNA", "outputIds":[ [ "S1Nhi94s0b" ] ] } ], "name":"Endpoint /forgot-password", "enabled":true, "description":"", "applicationId":"59fa4f7976b5470007a377b4", "_type":"flow", "_exportDate":"2017-11-06T23:00:26.915Z" }