{
  "name": "Register users and authenticate with magic links using Google Sheets",
  "nodes": [
    {
      "id": "dcaa8a9d-abdd-41a8-a359-868318d7f661",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        608
      ],
      "parameters": {
        "width": 1904,
        "height": 384,
        "content": "## 1. Login\nValidate username and password against Google Sheets, then reuse or issue a new token and redirect to the auth endpoint."
      }
    },
    {
      "id": "44324518-59de-4068-b49d-da5b9cabcf66",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        224
      ],
      "parameters": {
        "width": 1232,
        "height": 288,
        "content": "## 0. Register\nCollect an email address via form, generate credentials and a one-time token, save the user to Google Sheets, and send an onboarding email with the login link."
      }
    },
    {
      "id": "2472b7c4-cd6e-4194-8d12-59c4249ea7f3",
      "name": "Append or update row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        688,
        320
      ]
    },
    {
      "id": "d7f38863-74ee-4bb9-bb4d-2fd445594eea",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        1072
      ],
      "parameters": {
        "width": 1696,
        "height": 400,
        "content": "## 2. Auth\nValidate the one-time token via Google Sheets, generate a session id (sid), set an HttpOnly cookie, clear the token, and redirect to the profile page."
      }
    },
    {
      "id": "891d65a6-0b6c-474d-b029-d4702c8e4174",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        1552
      ],
      "parameters": {
        "width": 1424,
        "height": 416,
        "content": "## 3. Profile\nRead the sid cookie, look up the active session in Google Sheets, and render a profile page — or redirect to login if the session is invalid."
      }
    },
    {
      "id": "fee598fe-64d8-469e-be7d-745bd2be40e4",
      "name": "Prepare sid",
      "type": "n8n-nodes-base.code",
      "position": [
        1248,
        1088
      ]
    },
    {
      "id": "f8747e29-893d-4e5d-916c-bb56975eb881",
      "name": "Generate token",
      "type": "n8n-nodes-base.code",
      "position": [
        1328,
        816
      ]
    },
    {
      "id": "fd48786d-6e97-4361-bce0-40dc80596ba2",
      "name": "If has token in DB",
      "type": "n8n-nodes-base.if",
      "position": [
        976,
        640
      ]
    },
    {
      "id": "43b3e0a0-c749-4b08-8cc1-0e84fe357bed",
      "name": "If has token",
      "type": "n8n-nodes-base.if",
      "position": [
        464,
        1200
      ]
    },
    {
      "id": "18b1b20d-06cb-44c5-b295-2966ff15c84f",
      "name": "Search by token",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        736,
        1184
      ]
    },
    {
      "id": "dc27c8ff-75d6-4448-afb2-512d21cb08bf",
      "name": "On form register",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        224,
        320
      ]
    },
    {
      "id": "135c6108-45ec-45e6-b1e2-317e40a9004f",
      "name": "Create password and token",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        320
      ]
    },
    {
      "id": "fec2646b-dd15-4e8c-ad07-9fa7de065c9a",
      "name": "Send username/password",
      "type": "n8n-nodes-base.gmail",
      "position": [
        928,
        320
      ]
    },
    {
      "id": "f3241140-939d-4871-8bf3-25dc9c69b653",
      "name": "Notice register success",
      "type": "n8n-nodes-base.form",
      "position": [
        1184,
        320
      ]
    },
    {
      "id": "3da0b92c-edad-43e2-bcf1-e7bca316d7e9",
      "name": "On form login",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        224,
        736
      ]
    },
    {
      "id": "caceffd3-862e-4ffc-817e-ed1300546caa",
      "name": "Check username/password",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        480,
        736
      ]
    },
    {
      "id": "91c227fd-ecbb-4d9f-a608-4606453a0e93",
      "name": "If login success",
      "type": "n8n-nodes-base.if",
      "position": [
        720,
        736
      ]
    },
    {
      "id": "cedd4efe-c0e3-447b-a368-f4da51b0e004",
      "name": "Redirect to login form",
      "type": "n8n-nodes-base.form",
      "position": [
        992,
        816
      ]
    },
    {
      "id": "6c2905c0-67d1-4c29-8ee5-3676d6ab1255",
      "name": "Redirect to auth url",
      "type": "n8n-nodes-base.form",
      "position": [
        1312,
        624
      ]
    },
    {
      "id": "52426a88-2b8f-4839-b608-8c28e8cef5b1",
      "name": "Add token to DB",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1568,
        816
      ]
    },
    {
      "id": "1a3c065f-b882-4088-9c34-5ebbb4fb787a",
      "name": "Redirect to auth with new token",
      "type": "n8n-nodes-base.form",
      "position": [
        1840,
        816
      ]
    },
    {
      "id": "b4e2aebf-3f52-4234-ae86-f7c29f2a226d",
      "name": "Auth",
      "type": "n8n-nodes-base.webhook",
      "position": [
        208,
        1200
      ]
    },
    {
      "id": "340dcc3d-797c-44ca-a5ab-830687fbfffa",
      "name": "Invalid token",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        736,
        1344
      ]
    },
    {
      "id": "6119d68b-76d0-40ce-8ac1-df2253ca1a81",
      "name": "If token valid",
      "type": "n8n-nodes-base.if",
      "position": [
        976,
        1184
      ]
    },
    {
      "id": "d3588bf0-be76-4e85-9ac4-ce11de129b25",
      "name": "Redirect to login form1",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1248,
        1280
      ]
    },
    {
      "id": "4d02d506-b001-45b8-afab-32ac76d29896",
      "name": "Update sid",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1600,
        1088
      ]
    },
    {
      "id": "0960c383-12b3-4176-8501-3b85d9453256",
      "name": "Redirect to profile and set cookies",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1600,
        1280
      ]
    },
    {
      "id": "ed4908f3-50f0-4150-adbc-ca5b706a94e3",
      "name": "Profile",
      "type": "n8n-nodes-base.webhook",
      "position": [
        224,
        1712
      ]
    },
    {
      "id": "2d514f17-01f8-4410-a759-50289488502f",
      "name": "Check sid cookies header",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        1712
      ]
    },
    {
      "id": "9d062264-f2c0-4659-b68f-714b03389ac4",
      "name": "Search sid",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        672,
        1712
      ]
    },
    {
      "id": "d7dd2d42-a6bf-4adb-9571-1736cdb11703",
      "name": "If has data with sid",
      "type": "n8n-nodes-base.if",
      "position": [
        880,
        1712
      ]
    },
    {
      "id": "89d72c2d-0f9a-4e63-a1e0-7245cdafad39",
      "name": "Redirect to login",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1168,
        1808
      ]
    },
    {
      "id": "e13952a5-dc41-4429-a0ba-bb918e18e41f",
      "name": "Prepare html",
      "type": "n8n-nodes-base.code",
      "position": [
        1168,
        1568
      ]
    },
    {
      "id": "bbb5e14a-e5f1-4eff-acb0-e02203922a70",
      "name": "Show profile page",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1392,
        1568
      ]
    },
    {
      "id": "9496073d-aaa6-4d65-a2d5-a4ee7cd3c85c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        576
      ],
      "parameters": {
        "width": 880,
        "height": 720,
        "content": "## Overview\nThis workflow provides a lightweight authentication flow for n8n web portals using Google Sheets as a simple user/session store and email delivery for onboarding. It supports register, use"
      }
    }
  ],
  "connections": {
    "Auth": {
      "main": [
        [
          {
            "node": "If has token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Profile": {
      "main": [
        [
          {
            "node": "Check sid cookies header",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search sid": {
      "main": [
        [
          {
            "node": "If has data with sid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare sid": {
      "main": [
        [
          {
            "node": "Redirect to profile and set cookies",
            "type": "main",
            "index": 0
          },
          {
            "node": "Update sid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If has token": {
      "main": [
        [
          {
            "node": "Search by token",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Invalid token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare html": {
      "main": [
        [
          {
            "node": "Show profile page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form login": {
      "main": [
        [
          {
            "node": "Check username/password",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate token": {
      "main": [
        [
          {
            "node": "Add token to DB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If token valid": {
      "main": [
        [
          {
            "node": "Prepare sid",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Redirect to login form1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add token to DB": {
      "main": [
        [
          {
            "node": "Redirect to auth with new token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search by token": {
      "main": [
        [
          {
            "node": "If token valid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If login success": {
      "main": [
        [
          {
            "node": "If has token in DB",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Redirect to login form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form register": {
      "main": [
        [
          {
            "node": "Create password and token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If has token in DB": {
      "main": [
        [
          {
            "node": "Redirect to auth url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Generate token",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If has data with sid": {
      "main": [
        [
          {
            "node": "Prepare html",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Redirect to login",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send username/password": {
      "main": [
        [
          {
            "node": "Notice register success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check username/password": {
      "main": [
        [
          {
            "node": "If login success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check sid cookies header": {
      "main": [
        [
          {
            "node": "Search sid",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create password and token": {
      "main": [
        [
          {
            "node": "Append or update row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append or update row in sheet": {
      "main": [
        [
          {
            "node": "Send username/password",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}