{"flow":{"id":23,"summary":"Upon new user signup, check for existence in postgres, hash password, add record to postgres and airtable, send an email to new user.","versions":[75,76,82,93,111,115,127,128,129,138,140],"created_by":"rossmccrann","created_at":"2022-08-09T13:25:42.270Z","votes":2,"approved":true,"apps":["postgresql","airtable","smtp"],"value":{"modules":[{"id":"a","value":{"type":"rawscript","content":"import * as wmill from \"https://deno.land/x/windmill@v1.27.2/mod.ts\";\nimport { Client } from \"https://deno.land/x/postgres@v0.16.1/mod.ts\";\n\nexport async function main(\n  db: wmill.Resource<\"postgresql\">,\n  email: string,\n) {\n  db.database = db.dbname;\n  db.hostname = db.host;\n  const client = new Client(db);\n  await client.connect();\n\n  const check_user_query = `SELECT user_id FROM usr WHERE email='${email}'`;\n  let check_user = await client.queryObject(check_user_query);\n\n  return (check_user[\"rows\"] ? [`${email}`] : []);\n}\n","language":"deno","input_transforms":{"db":{"type":"static","value":"$res:"},"email":{"type":"static","value":""}}},"summary":"Check if the user email is currently present in the postgres database","stop_after_if":{"expr":"result.length == 0","skip_if_stopped":true}},{"id":"b","value":{"type":"forloopflow","modules":[{"id":"c","value":{"path":"hub/137/hash_password_with_random_salt","type":"script","input_transforms":{"password":{"type":"static","value":""}}},"summary":"Hash the new user password."},{"id":"d","value":{"path":"hub/130/execute_custom_query","type":"script","input_transforms":{"db":{"type":"static","value":"$res:"},"query":{"expr":"`INSERT INTO usr (email, password, name) VALUES ('${flow_input.email}', '${previous_result}', '${flow_input.name}');`","type":"javascript","value":"INSERT INTO usr (email, password, name) VALUES ('${flow_input.email}', '${previous_result}', '${flow_input.name}');"}}},"summary":"Insert a new row into the postgresql database."},{"id":"e","value":{"path":"hub/145/create_single_record","type":"script","input_transforms":{"at_con":{"type":"static","value":{"apiKey":""}},"at_table":{"type":"static","value":{"baseId":"","tableName":""}},"new_record":{"expr":"{\"email\": flow_input.email, \"password\": step(2), \"name\": flow_input.name}","type":"javascript"}}},"summary":"Create a new record in an Airtable table."},{"id":"f","value":{"path":"hub/209/send_quick_email","type":"script","input_transforms":{"userId":{"type":"static","value":"me"},"message":{"type":"static","value":""},"subject":{"type":"static","value":"Welcome To Windmill!"},"to_email":{"type":"static","value":""},"gmail_auth":{"type":"static","value":"$res:"}}},"summary":"Sends a welcome email to the new users email via gmail"}],"iterator":{"expr":"result","type":"javascript"},"parallel":false,"skip_failures":true},"input_transforms":{}}]},"schema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":[],"properties":{"name":{"type":"string","format":"","description":""},"email":{"type":"string","format":"","description":""},"password":{"type":"string","format":"","description":""}}},"description":"","recording":null,"vcreated_at":"2022-11-26T23:12:31.684Z","vcreated_by":"admin","comments":[]}}