User Registration
Implement user registration in your application.
Registration Methods
| Method | Flow |
|---|---|
| Email/Password | User provides email + password |
| Social Login | OAuth via Google, GitHub, LinkedIn, Facebook |
| Custom Database | Authenticate against existing database |
Email/Password Registration
Implementation Examples
- Next.js SDK
- Python / Django
- cURL / API
'use client';
import { useRegistration } from '@syauth/nextjs';
// ... component code ...
SyAuth handles Django user creation automatically upon login. For programmatic registration (e.g., custom forms), use the API directly:
import requests
def register_user(email, password, first_name, last_name):
url = "https://api.syauth.com/e/v1/register/"
payload = {
"email": email,
"password": password,
"first_name": first_name,
"last_name": last_name
}
headers = {
"Content-Type": "application/json",
"X-API-Key": "your-api-key"
}
response = requests.post(url, json=payload, headers=headers)
return response.json()
curl -X POST https://api.syauth.com/e/v1/register/ \
-H "Content-Type: application/json" \
-H "X-API-Key: your-api-key" \
-d '{
"email": "[email protected]",
"password": "SecurePass123!",
"first_name": "John",
"last_name": "Doe"
}'
Required Fields
| Field | Required | Description |
|---|---|---|
email | ✅ | Valid email address |
password | ✅ | Minimum 8 characters |
first_name | ❌ | User's first name |
last_name | ❌ | User's last name |
Password Requirements
Passwords must meet these requirements:
- Minimum 8 characters
- At least one uppercase letter
- At least one lowercase letter
- At least one number
- At least one special character
Via Universal Login
When using Universal Login, users can register directly:
const { loginWithRedirect } = useSyAuth();
// Redirect to Universal Login which has both login and register options
loginWithRedirect();
The Universal Login page includes a "Create account" link.
Registration API
For custom implementations:
POST https://api.syauth.com/e/v1/register/
Content-Type: application/json
X-API-Key: your-api-key
{
"email": "[email protected]",
"password": "SecurePass123!",
"first_name": "John",
"last_name": "Doe"
}
Response:
{
"success": true,
"message": "Registration successful. Please verify your email.",
"user": {
"id": "uuid",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"email_verified": false
}
}
Post-Registration Flow
After registration:
- Verification Email Sent - User receives email with verification code
- User Verifies Email - Clicks link or enters code
- Account Activated - User can now log in
Register → Email Sent → Verify Code → Account Active → Login
Error Handling
| Error | Description | Solution |
|---|---|---|
email_already_exists | Email already registered | Prompt to login instead |
invalid_email | Email format invalid | Validate email format |
weak_password | Password doesn't meet requirements | Show requirements |
invalid_api_key | Missing or invalid API key | Check configuration |
const { register, error } = useRegistration();
// Error is a string with the error message
if (error === 'email_already_exists') {
// Handle duplicate email
}
Configuration
Registration requires an API key:
# .env.local
NEXT_PUBLIC_SYAUTH_API_KEY=your-api-key
Get your API key from the Dashboard under your Application settings.
Next Steps
- Email Verification - Complete the registration flow
- User Profiles - Update user information