Skip to content

Replace password login with Hack Club Auth OAuth and sync signed-in users to Airtable _users - #26

Draft
scooterthedev with Copilot wants to merge 2 commits into
mainfrom
copilot/replace-login-with-hca-auth
Draft

Replace password login with Hack Club Auth OAuth and sync signed-in users to Airtable _users#26
scooterthedev with Copilot wants to merge 2 commits into
mainfrom
copilot/replace-login-with-hca-auth

Conversation

Copilot AI commented May 18, 2026

Copy link
Copy Markdown

This change replaces /login password auth with Hack Club Auth and provisions/updates signed-in users in Airtable _users with the requested identity and account fields. It removes the active password-login path and uses Hack Club OAuth as the login entrypoint.

  • Auth flow migration (password → Hack Club OAuth)

    • Replaced login UI email/password form with a single Hack Club Auth action.
    • Implemented OAuth start + callback flow in server/authRoutes.js:
      • state generation + validation
      • callback TTL guard
      • code exchange + profile fetch
      • session hydration (userId, hackclubSub)
    • Removed /api/auth/password/login usage and route path from the active login flow.
  • Scopes enforcement

    • Updated auth URL construction to always request:
      • email name profile birthdate address verification_status slack_id basic_info
    • Scope merging now appends required scopes even when HC_SCOPES is configured.
  • User persistence updates

    • Extended users schema/backfill:
      • slack_username
      • last_sign_in_at
    • Updated Hack Club upsert mapping to persist Slack username and refresh last_sign_in_at on each sign-in.
    • Changed default role from member to user to match requested defaults.
  • Airtable _users upsert on sign-in

    • Added targeted _users upsert helper in server/airtable.js.
    • On successful OAuth callback, upserts one _users record keyed by user_id with:
      • user_id, Name, bricks, slack_id, slack username, role, last sign in, created at, email, hackatime hours
    • Defaults applied per requirement (bricks=0, role=user, hackatime hours=0 when absent).
  • Representative snippet

    const fields = {
      user_id: Number(user.id),
      Name: user.name ?? profile.name ?? "",
      bricks: Number(user.coins ?? 0),
      slack_id: user.slack_id ?? profile.slack_id ?? null,
      "slack username": user.slack_username ?? profile.slack_username ?? null,
      role: user.role || "user",
      "last sign in": asIso(user.last_sign_in_at, new Date().toISOString()),
      "created at": asIso(user.created_at, new Date().toISOString()),
      email: user.email ?? profile.email ?? null,
      "hackatime hours": Number(user.hackatime_hours ?? 0),
    };
Original prompt

Create me a custom agent that using Hack Club auth (outlined here: https://auth.hackclub.com/docs/welcome). Replace the /login with HCA auth. Make sure to request the scopes:

email, name, profile, birthdate, address, verification_status, slack_id, basic_info. Then put it in an airtable base called _users with the colunm data being user_id starting from 1, Name from HCA name, bricks (ie. the currency, they start at 0), slack_id, slack username, role (defualt being user), last sign in, created at, email from HCA email, hackatime hours. All the envs are right. Make sure to remove the regular password auth too.

Created from VS Code.

Copilot AI changed the title [WIP] Replace login with Hack Club auth Replace password login with Hack Club Auth OAuth and sync signed-in users to Airtable _users May 18, 2026
Copilot AI requested a review from scooterthedev May 18, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants