mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 20:01:09 +02:00
🐛 fix(auth): require name field in registration forms
Add required name field (min 2 chars) to all registration forms to fix Better Auth validation error. Updates backend DTO, shared-auth service, shared-auth-ui RegisterPage component, i18n translations, and all app auth stores and register pages.
This commit is contained in:
parent
11324b5e68
commit
d3e11b320a
28 changed files with 151 additions and 56 deletions
|
|
@ -111,16 +111,16 @@ export const authStore = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sign up with email and password
|
||||
* Sign up with email, password, and name
|
||||
*/
|
||||
async signUp(email: string, password: string) {
|
||||
async signUp(email: string, password: string, name: string) {
|
||||
const authService = await getAuthService();
|
||||
if (!authService) {
|
||||
return { success: false, error: 'Auth not available on server', needsVerification: false };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await authService.signUp(email, password);
|
||||
const result = await authService.signUp(email, password, name);
|
||||
|
||||
if (!result.success) {
|
||||
return { success: false, error: result.error || 'Signup failed', needsVerification: false };
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
// Get translations based on current locale
|
||||
const translations = $derived(getRegisterTranslations($locale || 'de'));
|
||||
|
||||
async function handleSignUp(email: string, password: string) {
|
||||
return authStore.signUp(email, password);
|
||||
async function handleSignUp(email: string, password: string, name: string) {
|
||||
return authStore.signUp(email, password, name);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -110,16 +110,16 @@ export const authStore = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sign up with email and password
|
||||
* Sign up with email, password, and name
|
||||
*/
|
||||
async signUp(email: string, password: string) {
|
||||
async signUp(email: string, password: string, name: string) {
|
||||
const authService = await getAuthService();
|
||||
if (!authService) {
|
||||
return { success: false, error: 'Auth not available on server', needsVerification: false };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await authService.signUp(email, password);
|
||||
const result = await authService.signUp(email, password, name);
|
||||
|
||||
if (!result.success) {
|
||||
return { success: false, error: result.error || 'Signup failed', needsVerification: false };
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
// Get translations based on current locale
|
||||
const translations = $derived(getRegisterTranslations($locale || 'de'));
|
||||
|
||||
async function handleSignUp(email: string, password: string) {
|
||||
return authStore.signUp(email, password);
|
||||
async function handleSignUp(email: string, password: string, name: string) {
|
||||
return authStore.signUp(email, password, name);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -110,16 +110,16 @@ export const authStore = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sign up with email and password
|
||||
* Sign up with email, password, and name
|
||||
*/
|
||||
async signUp(email: string, password: string) {
|
||||
async signUp(email: string, password: string, name: string) {
|
||||
const authService = await getAuthService();
|
||||
if (!authService) {
|
||||
return { success: false, error: 'Auth not available on server', needsVerification: false };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await authService.signUp(email, password);
|
||||
const result = await authService.signUp(email, password, name);
|
||||
|
||||
if (!result.success) {
|
||||
return { success: false, error: result.error || 'Signup failed', needsVerification: false };
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
// Get translations based on current locale
|
||||
const translations = $derived(getRegisterTranslations($locale || 'de'));
|
||||
|
||||
async function handleSignUp(email: string, password: string) {
|
||||
return authStore.signUp(email, password);
|
||||
async function handleSignUp(email: string, password: string, name: string) {
|
||||
return authStore.signUp(email, password, name);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -110,16 +110,16 @@ export const authStore = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sign up with email and password
|
||||
* Sign up with email, password, and name
|
||||
*/
|
||||
async signUp(email: string, password: string) {
|
||||
async signUp(email: string, password: string, name: string) {
|
||||
const authService = await getAuthService();
|
||||
if (!authService) {
|
||||
return { success: false, error: 'Auth not available on server', needsVerification: false };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await authService.signUp(email, password);
|
||||
const result = await authService.signUp(email, password, name);
|
||||
|
||||
if (!result.success) {
|
||||
return { success: false, error: result.error || 'Signup failed', needsVerification: false };
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
const translations = $derived(getRegisterTranslations($locale || 'de'));
|
||||
|
||||
async function handleSignUp(email: string, password: string) {
|
||||
return authStore.signUp(email, password);
|
||||
async function handleSignUp(email: string, password: string, name: string) {
|
||||
return authStore.signUp(email, password, name);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -116,19 +116,20 @@ export const authStore = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sign up with email and password
|
||||
* Sign up with email, password and name
|
||||
* @param email User email
|
||||
* @param password User password
|
||||
* @param name User's display name
|
||||
* @param referralCode Optional referral code for bonus credits
|
||||
*/
|
||||
async signUp(email: string, password: string, referralCode?: string) {
|
||||
async signUp(email: string, password: string, name: string, referralCode?: string) {
|
||||
const authService = await getAuthService();
|
||||
if (!authService) {
|
||||
return { success: false, error: 'Auth not available on server', needsVerification: false };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await authService.signUp(email, password, referralCode);
|
||||
const result = await authService.signUp(email, password, name, referralCode);
|
||||
|
||||
if (!result.success) {
|
||||
return { success: false, error: result.error || 'Signup failed', needsVerification: false };
|
||||
|
|
|
|||
|
|
@ -9,8 +9,13 @@
|
|||
// Get referral code from URL if present
|
||||
let initialReferralCode = $derived($page.url.searchParams.get('ref') || '');
|
||||
|
||||
async function handleSignUp(email: string, password: string, referralCode?: string) {
|
||||
return authStore.signUp(email, password, referralCode);
|
||||
async function handleSignUp(
|
||||
email: string,
|
||||
password: string,
|
||||
name: string,
|
||||
referralCode?: string
|
||||
) {
|
||||
return authStore.signUp(email, password, name, referralCode);
|
||||
}
|
||||
|
||||
async function handleValidateReferralCode(code: string) {
|
||||
|
|
|
|||
|
|
@ -92,10 +92,10 @@ export const authStore = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sign up with email and password
|
||||
* Sign up with email, password, and name
|
||||
*/
|
||||
async signUp(email: string, password: string) {
|
||||
const result = await authService.signUp(email, password);
|
||||
async signUp(email: string, password: string, name: string) {
|
||||
const result = await authService.signUp(email, password, name);
|
||||
if (result.success && !result.needsVerification) {
|
||||
const userData = await authService.getUserFromToken();
|
||||
user = toManaUser(userData);
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@
|
|||
import AppSlider from '$lib/components/AppSlider.svelte';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
async function handleSignUp(email: string, password: string) {
|
||||
return authStore.signUp(email, password);
|
||||
async function handleSignUp(email: string, password: string, name: string) {
|
||||
return authStore.signUp(email, password, name);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ export const authStore = {
|
|||
}
|
||||
},
|
||||
|
||||
async signUp(email: string, password: string): Promise<AuthResult> {
|
||||
async signUp(email: string, password: string, name: string): Promise<AuthResult> {
|
||||
const authService = await getAuthService();
|
||||
if (!authService) {
|
||||
return { success: false, error: 'Auth service not available' };
|
||||
|
|
@ -123,7 +123,7 @@ export const authStore = {
|
|||
|
||||
try {
|
||||
loading = true;
|
||||
const result = await authService.signUp(email, password);
|
||||
const result = await authService.signUp(email, password, name);
|
||||
|
||||
if (result.success) {
|
||||
// Auto-login after signup
|
||||
|
|
|
|||
|
|
@ -143,16 +143,16 @@ export const authStore = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sign up with email and password
|
||||
* Sign up with email, password, and name
|
||||
*/
|
||||
async signUp(email: string, password: string) {
|
||||
async signUp(email: string, password: string, name: string) {
|
||||
const authService = getAuthService();
|
||||
if (!authService) {
|
||||
return { success: false, error: 'Auth not available on server', needsVerification: false };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await authService.signUp(email, password);
|
||||
const result = await authService.signUp(email, password, name);
|
||||
|
||||
if (!result.success) {
|
||||
return { success: false, error: result.error || 'Signup failed', needsVerification: false };
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
// Get translations based on current locale
|
||||
const translations = $derived(getRegisterTranslations($locale || 'de'));
|
||||
|
||||
async function handleSignUp(email: string, password: string) {
|
||||
return authStore.signUp(email, password);
|
||||
async function handleSignUp(email: string, password: string, name: string) {
|
||||
return authStore.signUp(email, password, name);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -131,16 +131,16 @@ export const authStore = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Sign up with email and password
|
||||
* Sign up with email, password, and name
|
||||
*/
|
||||
async signUp(email: string, password: string) {
|
||||
async signUp(email: string, password: string, name: string) {
|
||||
const authService = getAuthService();
|
||||
if (!authService) {
|
||||
return { success: false, error: 'Auth not available on server', needsVerification: false };
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await authService.signUp(email, password);
|
||||
const result = await authService.signUp(email, password, name);
|
||||
|
||||
if (!result.success) {
|
||||
return { success: false, error: result.error || 'Signup failed', needsVerification: false };
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
const translations = $derived(getRegisterTranslations($locale || 'de'));
|
||||
|
||||
async function handleSignUp(email: string, password: string) {
|
||||
return authStore.signUp(email, password);
|
||||
async function handleSignUp(email: string, password: string, name: string) {
|
||||
return authStore.signUp(email, password, name);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue