mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 13:55:23 +02:00
feat(auth): add sign up flow with email domain validation and password confirm
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
c1f809dfdb
commit
b88ca57c95
@@ -8,6 +8,26 @@ export interface AuthSession {
|
||||
user: { id: string; email: string };
|
||||
}
|
||||
|
||||
export async function signUp(email: string, password: string): Promise<void> {
|
||||
if (!email.toLowerCase().endsWith(ALLOWED_DOMAIN)) {
|
||||
throw new Error(`Only ${ALLOWED_DOMAIN} email addresses are allowed.`);
|
||||
}
|
||||
|
||||
const response = await fetch(`${SUPABASE_URL}/auth/v1/signup`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'apikey': SUPABASE_ANON_KEY,
|
||||
},
|
||||
body: JSON.stringify({ email, password }),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const err = await response.json().catch(() => ({}));
|
||||
throw new Error(err.error_description || err.message || 'Registration failed.');
|
||||
}
|
||||
}
|
||||
|
||||
export async function signIn(email: string, password: string): Promise<AuthSession> {
|
||||
if (!email.toLowerCase().endsWith(ALLOWED_DOMAIN)) {
|
||||
throw new Error(`Only ${ALLOWED_DOMAIN} email addresses are allowed.`);
|
||||
|
||||
Reference in New Issue
Block a user