Discord Auth Engineering Notes
The site authentication system has been implemented using Supabase Auth with Discord as the OAuth provider. This allows users to log in using their existing Discord credentials, enabling the site to recognize guild members and eventually gate content or features based on roles.
auth-manager.js script detects the new session and updates the UI to show the user’s avatar and username.The architecture uses ES6 Modules to maintain a clean separation between configuration, logic, and UI.
| File | Location | Description |
|---|---|---|
| Auth Header | _includes/auth-header.html |
The UI Widget. Contains the HTML for the button and profile card, plus CSS for styling. It uses a “polling” script to wait for the manager to load. |
| Auth Manager | /assets/js/auth-manager.js |
The Controller. An ES6 Module that handles the logic. It initializes the session, handles login/logout clicks, and updates the UI. It attaches itself to window.authManager so the HTML can access it. |
| Supabase Client | /assets/js/supabaseClient.js |
The Config. A single source of truth for API Keys and the Supabase Client instance. It is imported by the Manager. |
| Default Layout | _layouts/default.html |
The Loader. Loads the Auth Manager script as a type="module" so that it can use imports. |
To add the login widget to a new page, simply add the following Liquid tag:
```liquid