@@ -25,9 +25,7 @@ class MongoDbVerificationCodeStorageService
25
25
required Logger log,
26
26
this .codeExpiryDuration = const Duration (minutes: 15 ),
27
27
}) : _connectionManager = connectionManager,
28
- _log = log {
29
- _init ();
30
- }
28
+ _log = log;
31
29
32
30
final MongoDbConnectionManager _connectionManager;
33
31
final Logger _log;
@@ -39,39 +37,6 @@ class MongoDbVerificationCodeStorageService
39
37
DbCollection get _collection =>
40
38
_connectionManager.db.collection (kVerificationCodesCollection);
41
39
42
- /// Initializes the service by ensuring required indexes exist.
43
- Future <void > _init () async {
44
- try {
45
- _log.info ('Ensuring indexes exist for verification codes...' );
46
- final command = {
47
- 'createIndexes' : kVerificationCodesCollection,
48
- 'indexes' : [
49
- // TTL index for automatic document expiration
50
- {
51
- 'key' : {'expiresAt' : 1 },
52
- 'name' : 'expiresAt_ttl_index' ,
53
- 'expireAfterSeconds' : 0 ,
54
- },
55
- // Unique index to ensure only one code per email
56
- {
57
- 'key' : {'email' : 1 },
58
- 'name' : 'email_unique_index' ,
59
- 'unique' : true ,
60
- }
61
- ]
62
- };
63
- await _connectionManager.db.runCommand (command);
64
- _log.info ('Verification codes indexes are set up correctly.' );
65
- } catch (e, s) {
66
- _log.severe (
67
- 'Failed to create indexes for verification codes collection.' ,
68
- e,
69
- s,
70
- );
71
- rethrow ;
72
- }
73
- }
74
-
75
40
String _generateNumericCode ({int length = 6 }) {
76
41
final buffer = StringBuffer ();
77
42
for (var i = 0 ; i < length; i++ ) {
0 commit comments