@@ -6,7 +6,7 @@ import 'package:ht_data_repository/ht_data_repository.dart';
66import 'package:ht_email_repository/ht_email_repository.dart' ;
77import 'package:ht_shared/ht_shared.dart' ;
88import 'package:logging/logging.dart' ;
9- import 'package:uuid/uuid .dart' ;
9+ import 'package:mongo_dart/mongo_dart .dart' ;
1010
1111/// {@template auth_service}
1212/// Service responsible for orchestrating authentication logic on the backend.
@@ -25,7 +25,6 @@ class AuthService {
2525 required HtDataRepository <UserContentPreferences >
2626 userContentPreferencesRepository,
2727 required PermissionService permissionService,
28- required Uuid uuidGenerator,
2928 required Logger log,
3029 }) : _userRepository = userRepository,
3130 _authTokenService = authTokenService,
@@ -34,7 +33,6 @@ class AuthService {
3433 _emailRepository = emailRepository,
3534 _userAppSettingsRepository = userAppSettingsRepository,
3635 _userContentPreferencesRepository = userContentPreferencesRepository,
37- _uuid = uuidGenerator,
3836 _log = log;
3937
4038 final HtDataRepository <User > _userRepository;
@@ -46,7 +44,6 @@ class AuthService {
4644 _userContentPreferencesRepository;
4745 final PermissionService _permissionService;
4846 final Logger _log;
49- final Uuid _uuid;
5047
5148 /// Initiates the email sign-in process.
5249 ///
@@ -212,7 +209,7 @@ class AuthService {
212209 // All new users created via the public API get the standard role.
213210 // Admin users must be provisioned out-of-band (e.g., via fixtures).
214211 user = User (
215- id: _uuid. v4 () ,
212+ id: ObjectId ().oid ,
216213 email: email,
217214 appRole: AppUserRole .standardUser,
218215 dashboardRole: DashboardUserRole .none,
@@ -268,11 +265,12 @@ class AuthService {
268265 // 1. Create anonymous user
269266 User user;
270267 try {
268+ final newId = ObjectId ().oid;
271269 user = User (
272- id: _uuid. v4 () ,
270+ id: newId ,
273271 // Use a unique placeholder email for anonymous users to satisfy the
274272 // non-nullable email constraint.
275- email: '${ _uuid . v4 ()} @anonymous.com' ,
273+ email: '$newId @anonymous.com' ,
276274 appRole: AppUserRole .guestUser,
277275 dashboardRole: DashboardUserRole .none,
278276 createdAt: DateTime .now (),
0 commit comments