@@ -20,23 +20,23 @@ class AuthService {
2020 required HtEmailRepository emailRepository,
2121 required HtDataRepository <UserAppSettings > userAppSettingsRepository,
2222 required HtDataRepository <UserContentPreferences >
23- userContentPreferencesRepository,
23+ userContentPreferencesRepository,
2424 required Uuid uuidGenerator,
25- }) : _userRepository = userRepository,
26- _authTokenService = authTokenService,
27- _verificationCodeStorageService = verificationCodeStorageService,
28- _emailRepository = emailRepository,
29- _userAppSettingsRepository = userAppSettingsRepository,
30- _userContentPreferencesRepository = userContentPreferencesRepository,
31- _uuid = uuidGenerator;
25+ }) : _userRepository = userRepository,
26+ _authTokenService = authTokenService,
27+ _verificationCodeStorageService = verificationCodeStorageService,
28+ _emailRepository = emailRepository,
29+ _userAppSettingsRepository = userAppSettingsRepository,
30+ _userContentPreferencesRepository = userContentPreferencesRepository,
31+ _uuid = uuidGenerator;
3232
3333 final HtDataRepository <User > _userRepository;
3434 final AuthTokenService _authTokenService;
3535 final VerificationCodeStorageService _verificationCodeStorageService;
3636 final HtEmailRepository _emailRepository;
3737 final HtDataRepository <UserAppSettings > _userAppSettingsRepository;
3838 final HtDataRepository <UserContentPreferences >
39- _userContentPreferencesRepository;
39+ _userContentPreferencesRepository;
4040 final Uuid _uuid;
4141
4242 /// Initiates the email sign-in process.
@@ -47,16 +47,11 @@ class AuthService {
4747 Future <void > initiateEmailSignIn (String email) async {
4848 try {
4949 // Generate and store the code for standard sign-in
50- final code =
51- await _verificationCodeStorageService.generateAndStoreSignInCode (
52- email,
53- );
50+ final code = await _verificationCodeStorageService
51+ .generateAndStoreSignInCode (email);
5452
5553 // Send the code via email
56- await _emailRepository.sendOtpEmail (
57- recipientEmail: email,
58- otpCode: code,
59- );
54+ await _emailRepository.sendOtpEmail (recipientEmail: email, otpCode: code);
6055 print ('Initiated email sign-in for $email , code sent.' );
6156 } on HtHttpException {
6257 // Propagate known exceptions from dependencies
@@ -83,11 +78,8 @@ class AuthService {
8378 // User? currentAuthUser, // Parameter for potential future linking logic
8479 ) async {
8580 // 1. Validate the code for standard sign-in
86- final isValidCode =
87- await _verificationCodeStorageService.validateSignInCode (
88- email,
89- code,
90- );
81+ final isValidCode = await _verificationCodeStorageService
82+ .validateSignInCode (email, code);
9183 if (! isValidCode) {
9284 throw const InvalidInputException (
9385 'Invalid or expired verification code.' ,
@@ -312,11 +304,11 @@ class AuthService {
312304 // 2. Generate and store the link code.
313305 // The storage service itself might throw ConflictException if emailToLink
314306 // is pending for another user or if this user has a pending code.
315- final code =
316- await _verificationCodeStorageService .generateAndStoreLinkCode (
317- userId: anonymousUser.id,
318- emailToLink: emailToLink,
319- );
307+ final code = await _verificationCodeStorageService
308+ .generateAndStoreLinkCode (
309+ userId: anonymousUser.id,
310+ emailToLink: emailToLink,
311+ );
320312
321313 // 3. Send the code via email
322314 await _emailRepository.sendOtpEmail (
@@ -359,11 +351,11 @@ class AuthService {
359351
360352 try {
361353 // 1. Validate the link code and retrieve the email that was being linked.
362- final linkedEmail =
363- await _verificationCodeStorageService .validateAndRetrieveLinkedEmail (
364- userId: anonymousUser.id,
365- linkCode: codeFromUser,
366- );
354+ final linkedEmail = await _verificationCodeStorageService
355+ .validateAndRetrieveLinkedEmail (
356+ userId: anonymousUser.id,
357+ linkCode: codeFromUser,
358+ );
367359
368360 if (linkedEmail == null ) {
369361 throw const InvalidInputException (
@@ -446,9 +438,7 @@ class AuthService {
446438 // 2. Clear any pending verification codes for this user ID (linking).
447439 try {
448440 await _verificationCodeStorageService.clearLinkCode (userId);
449- print (
450- '[AuthService] Cleared link code for user ${userToDelete .id }.' ,
451- );
441+ print ('[AuthService] Cleared link code for user ${userToDelete .id }.' );
452442 } catch (e) {
453443 // Log but don't fail deletion if clearing codes fails
454444 print (
@@ -459,8 +449,9 @@ class AuthService {
459449 // 3. Clear any pending sign-in codes for the user's email (if they had one).
460450 if (userToDelete.email != null ) {
461451 try {
462- await _verificationCodeStorageService
463- .clearSignInCode (userToDelete.email! );
452+ await _verificationCodeStorageService.clearSignInCode (
453+ userToDelete.email! ,
454+ );
464455 print (
465456 '[AuthService] Cleared sign-in code for email ${userToDelete .email }.' ,
466457 );
@@ -488,9 +479,7 @@ class AuthService {
488479 } catch (e) {
489480 // Catch unexpected errors during orchestration
490481 print ('Error during deleteAccount for user $userId : $e ' );
491- throw OperationFailedException (
492- 'Failed to delete user account: $e ' ,
493- );
482+ throw OperationFailedException ('Failed to delete user account: $e ' );
494483 }
495484 }
496485}
0 commit comments