workflows.fit
Back to n8n workflows
n8n templateFreeBy NanaB

Build production-ready user authentication with Airtable and JWT

This n8n workflow provides a comprehensive solution for user authentication and management, leveraging Airtable as the backend database. It includes flows for user sign-up and login, aswell as the sample crud operatio...

Data & StorageDevelopmentCore NodesUtilitySticky NoteCryptoAirtableRespond To Webhook
Loading interactive preview...

Template notes

This n8n workflow provides a comprehensive solution for user authentication and management, leveraging Airtable as the backend database. It includes flows for user sign-up and login, aswell as the sample crud operations retrieving user details, and updating user information.

Youtube Video of me explaining the flow: https://www.youtube.com/watch?v=gKcGfyq3dPM

How it Works

User Sign-Up Flow 1. Receives POST request: A webhook listens for POST requests containing new user details (email, first name, last name, password). 2. Checks for existing email: The workflow queries Airtable to see if the submitted email already exists. 3. Handles email in use: If the email is found, it responds with {"response": "email in use"}. 4. Creates new user: If the email is unique, the password is SHA256 hashed (Base64 encoded), and the user's information (including the hashed password) is stored in Airtable. A successful response of {"response": "success"} is then sent.

User Login Flow 1. Receives POST request: A webhook listens for POST requests with user email and password for login. 2. Verifies user existence: It checks Airtable for a user with the provided email. If no user is found, it responds with a failure message ("wrong email"). 3. Compares passwords: If a user is found, the submitted password is hashed (SHA256, Base64 encoded) and compared with the stored hashed password in Airtable. 4. Responds with JWT or error: If passwords match, a JWT token containing the user's ID and email is issued. If they don't match, a "wrong password" response is sent.

Flows for a Logged-In User

These flows require a JWT-authenticated request.

Get User Details: 1. Webhook (GET): Receives a JWT-authenticated request. 2. Airtable (Read): Fetches the current user’s record using the jwtPayload.id. 3. Set Node ("Specify Current Details"): Maps fields like "First Name," "Last Name," "Email," and "Date" from Airtable to a standard output format.