Skip to content

Commit 8478bc1

Browse files
committed
refactor(auth): update repository calls
- Use named parameters for repo calls - Improves readability and maintainability
1 parent 6d7f68a commit 8478bc1

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

lib/src/services/auth_service.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class AuthService {
117117
email: email,
118118
isAnonymous: false, // Email verified user is not anonymous
119119
);
120-
user = await _userRepository.create(user); // Save the new user
120+
user = await _userRepository.create(item: user); // Save the new user
121121
print('Created new user: ${user.id}');
122122
}
123123
} on HtHttpException catch (e) {
@@ -157,7 +157,7 @@ class AuthService {
157157
isAnonymous: true,
158158
email: null, // Anonymous users don't have an email initially
159159
);
160-
user = await _userRepository.create(user);
160+
user = await _userRepository.create(item: user);
161161
print('Created anonymous user: ${user.id}');
162162
} on HtHttpException catch (e) {
163163
print('Error creating anonymous user: $e');
@@ -327,8 +327,8 @@ class AuthService {
327327
isAnonymous: false, // Now a permanent user
328328
);
329329
final permanentUser = await _userRepository.update(
330-
updatedUser.id,
331-
updatedUser,
330+
id: updatedUser.id,
331+
item: updatedUser,
332332
);
333333
print(
334334
'User ${permanentUser.id} successfully linked with email $linkedEmail.',
@@ -384,12 +384,12 @@ class AuthService {
384384
Future<void> deleteAccount({required String userId}) async {
385385
try {
386386
// Fetch the user first to get their email if needed for cleanup
387-
final userToDelete = await _userRepository.read(userId);
387+
final userToDelete = await _userRepository.read(id: userId);
388388
print('[AuthService] Found user ${userToDelete.id} for deletion.');
389389

390390
// 1. Delete the user record from the repository.
391391
// This implicitly invalidates tokens that rely on user lookup.
392-
await _userRepository.delete(userId);
392+
await _userRepository.delete(id: userId);
393393
print('[AuthService] User ${userToDelete.id} deleted from repository.');
394394

395395
// 2. Clear any pending verification codes for this user ID (linking).

lib/src/services/jwt_auth_token_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ class JwtAuthTokenService implements AuthTokenService {
162162
print('[validateToken] Attempting to fetch user with ID: $userId');
163163
// Fetch the full user object from the repository
164164
// This ensures the user still exists and is valid
165-
final user = await _userRepository.read(userId);
165+
final user = await _userRepository.read(id: userId);
166166
print('[validateToken] User repository read successful for ID: $userId');
167167
print('[validateToken] Token validated successfully for user ${user.id}');
168168
return user;

lib/src/services/simple_auth_token_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class SimpleAuthTokenService implements AuthTokenService {
4848
print(
4949
'[SimpleAuthTokenService] Attempting to read user from repository...',
5050
);
51-
final user = await _userRepository.read(userId);
51+
final user = await _userRepository.read(id: userId);
5252
print('[SimpleAuthTokenService] User read successful: ${user.id}');
5353
return user;
5454
} on NotFoundException {

0 commit comments

Comments
 (0)