Skip to content

Commit d3acf70

Browse files
committed
refactor(auth): pass auth user to complete sign-in
- Pass current user for data migration
1 parent 0820116 commit d3acf70

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

routes/api/v1/auth/verify-code.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Future<Response> onRequest(RequestContext context) async {
1818
// Read the AuthService provided by middleware
1919
final authService = context.read<AuthService>();
2020

21+
// Read the authenticated User from context (provided by authentication middleware)
22+
// This user might be null (if not authenticated) or an anonymous user.
23+
final authenticatedUser = context.read<User?>();
24+
2125
// Parse the request body
2226
final dynamic body;
2327
try {
@@ -63,7 +67,12 @@ Future<Response> onRequest(RequestContext context) async {
6367

6468
try {
6569
// Call the AuthService to handle the verification and sign-in logic
66-
final result = await authService.completeEmailSignIn(email, code);
70+
// Pass the current authenticated user for potential data migration.
71+
final result = await authService.completeEmailSignIn(
72+
email,
73+
code,
74+
currentAuthUser: authenticatedUser,
75+
);
6776

6877
// Create the specific payload containing user and token
6978
final authPayload = AuthSuccessResponse(

0 commit comments

Comments
 (0)