@lastbrain/module-auth 0.1.22 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/admin/signup-stats.d.ts +21 -0
- package/dist/api/admin/signup-stats.d.ts.map +1 -0
- package/dist/api/admin/signup-stats.js +75 -0
- package/dist/api/admin/users-by-source.d.ts +22 -0
- package/dist/api/admin/users-by-source.d.ts.map +1 -0
- package/dist/api/admin/users-by-source.js +56 -0
- package/dist/api/public/signup.d.ts +10 -0
- package/dist/api/public/signup.d.ts.map +1 -0
- package/dist/api/public/signup.js +71 -0
- package/dist/auth.build.config.d.ts.map +1 -1
- package/dist/auth.build.config.js +26 -0
- package/dist/components/AccountButton.d.ts.map +1 -1
- package/dist/index.d.ts +17 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -16
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -0
- package/dist/web/admin/signup-stats.d.ts +2 -0
- package/dist/web/admin/signup-stats.d.ts.map +1 -0
- package/dist/web/admin/signup-stats.js +50 -0
- package/dist/web/admin/user-detail.d.ts.map +1 -1
- package/dist/web/admin/user-detail.js +5 -1
- package/dist/web/admin/users/[id].js +1 -1
- package/dist/web/admin/users-by-signup-source.d.ts +2 -0
- package/dist/web/admin/users-by-signup-source.d.ts.map +1 -0
- package/dist/web/admin/users-by-signup-source.js +79 -0
- package/dist/web/auth/profile.js +18 -18
- package/dist/web/public/SignUpPage.d.ts.map +1 -1
- package/dist/web/public/SignUpPage.js +15 -23
- package/package.json +4 -4
- package/src/api/admin/signup-stats.ts +109 -0
- package/src/api/admin/users-by-source.ts +87 -0
- package/src/api/public/signup.ts +106 -0
- package/src/auth.build.config.ts +27 -0
- package/src/components/AccountButton.tsx +0 -1
- package/src/index.ts +17 -16
- package/src/server.ts +1 -0
- package/src/web/admin/signup-stats.tsx +304 -0
- package/src/web/admin/user-detail.tsx +17 -2
- package/src/web/admin/users/[id].tsx +1 -1
- package/src/web/admin/users-by-signup-source.tsx +262 -0
- package/src/web/admin/users.tsx +1 -1
- package/src/web/auth/profile.tsx +6 -6
- package/src/web/public/SignUpPage.tsx +16 -25
- package/supabase/migrations/20251112000000_user_init.sql +18 -1
- package/supabase/migrations/20251112000001_auto_profile_and_admin_view.sql +10 -2
- package/supabase/migrations/20251124000001_add_get_admin_user_details.sql +2 -1
- package/supabase/migrations-down/20251204000000_add_signup_source.sql +12 -0
|
@@ -33,7 +33,7 @@ function SignUpForm() {
|
|
|
33
33
|
const [success, setSuccess] = useState<string | null>(null);
|
|
34
34
|
|
|
35
35
|
// Récupérer le paramètre redirect
|
|
36
|
-
const redirectUrl = searchParams
|
|
36
|
+
const redirectUrl = searchParams?.get("redirect") || "";
|
|
37
37
|
|
|
38
38
|
const handleSubmit = async (event: React.FormEvent<HTMLFormElement>) => {
|
|
39
39
|
event.preventDefault();
|
|
@@ -53,43 +53,34 @@ function SignUpForm() {
|
|
|
53
53
|
setLoading(true);
|
|
54
54
|
|
|
55
55
|
try {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// Appeler la nouvelle route API signup (signupSource sera déterminé côté serveur via VERCEL_URL)
|
|
57
|
+
const response = await fetch("/api/auth/signup", {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
},
|
|
62
|
+
body: JSON.stringify({
|
|
58
63
|
email,
|
|
59
64
|
password,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
full_name: fullName,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
});
|
|
65
|
+
fullName,
|
|
66
|
+
}),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const result = await response.json();
|
|
69
70
|
|
|
70
|
-
if (
|
|
71
|
-
setError(
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
setError(result.error || "Erreur lors de l'inscription");
|
|
72
73
|
return;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
// Si la confirmation par email est requise
|
|
76
|
-
if (data.user && !data.session) {
|
|
77
|
+
if (result.data.user && !result.data.session) {
|
|
77
78
|
setSuccess(
|
|
78
79
|
"Compte créé avec succès ! Veuillez vérifier votre email pour confirmer votre compte."
|
|
79
80
|
);
|
|
80
81
|
return;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
// Si l'utilisateur est directement connecté (confirmation email désactivée)
|
|
84
|
-
if (data.session) {
|
|
85
|
-
if (redirectUrl) {
|
|
86
|
-
window.location.href = redirectUrl;
|
|
87
|
-
} else {
|
|
88
|
-
window.location.href = "/auth/dashboard";
|
|
89
|
-
}
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
84
|
setSuccess("Compte créé. Vous pouvez désormais vous connecter.");
|
|
94
85
|
setTimeout(() => {
|
|
95
86
|
if (redirectUrl) {
|
|
@@ -177,4 +177,21 @@ CREATE TRIGGER set_user_notifications_updated_at
|
|
|
177
177
|
-- =====================================================
|
|
178
178
|
-- Enable Realtime for user_notifications
|
|
179
179
|
-- =====================================================
|
|
180
|
-
ALTER PUBLICATION supabase_realtime ADD TABLE public.user_notifications;
|
|
180
|
+
ALTER PUBLICATION supabase_realtime ADD TABLE public.user_notifications;
|
|
181
|
+
|
|
182
|
+
-- Add signup_source to user_profil table
|
|
183
|
+
-- Track where users signed up from (e.g., 'lastbrain', 'recipe', etc.)
|
|
184
|
+
|
|
185
|
+
-- Add the column
|
|
186
|
+
ALTER TABLE public.user_profil
|
|
187
|
+
ADD COLUMN IF NOT EXISTS signup_source TEXT DEFAULT 'lastbrain';
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
-- Create an index for stats queries
|
|
192
|
+
CREATE INDEX IF NOT EXISTS idx_user_profil_signup_source
|
|
193
|
+
ON public.user_profil(signup_source);
|
|
194
|
+
|
|
195
|
+
-- Create an index for date range queries
|
|
196
|
+
CREATE INDEX IF NOT EXISTS idx_user_profil_created_at_source
|
|
197
|
+
ON public.user_profil(signup_source, created_at DESC);
|
|
@@ -19,9 +19,17 @@ END $$;
|
|
|
19
19
|
-- Function to create user profile automatically
|
|
20
20
|
CREATE OR REPLACE FUNCTION public.handle_new_user()
|
|
21
21
|
RETURNS TRIGGER AS $$
|
|
22
|
+
DECLARE
|
|
23
|
+
signup_source_value TEXT;
|
|
22
24
|
BEGIN
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
-- Extract signup_source from user metadata if present
|
|
26
|
+
signup_source_value := COALESCE(
|
|
27
|
+
NEW.raw_user_meta_data->>'signup_source',
|
|
28
|
+
'lastbrain'
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
INSERT INTO public.user_profil (owner_id, signup_source, created_at, updated_at)
|
|
32
|
+
VALUES (NEW.id, signup_source_value, now(), now());
|
|
25
33
|
RETURN NEW;
|
|
26
34
|
EXCEPTION
|
|
27
35
|
WHEN unique_violation THEN
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- Rollback: Remove signup_source from user_profil table
|
|
2
|
+
|
|
3
|
+
-- Drop indexes
|
|
4
|
+
DROP INDEX IF EXISTS public.idx_user_profil_created_at_source;
|
|
5
|
+
DROP INDEX IF EXISTS public.idx_user_profil_signup_source;
|
|
6
|
+
|
|
7
|
+
-- Drop constraint and column
|
|
8
|
+
ALTER TABLE public.user_profil
|
|
9
|
+
DROP CONSTRAINT IF EXISTS user_profil_signup_source_check;
|
|
10
|
+
|
|
11
|
+
ALTER TABLE public.user_profil
|
|
12
|
+
DROP COLUMN IF EXISTS signup_source;
|