@@ -18,17 +18,25 @@ class AuthService {
18
18
required AuthTokenService authTokenService,
19
19
required VerificationCodeStorageService verificationCodeStorageService,
20
20
required HtEmailRepository emailRepository,
21
+ required HtDataRepository <UserAppSettings > userAppSettingsRepository,
22
+ required HtDataRepository <UserContentPreferences >
23
+ userContentPreferencesRepository,
21
24
required Uuid uuidGenerator,
22
25
}) : _userRepository = userRepository,
23
26
_authTokenService = authTokenService,
24
27
_verificationCodeStorageService = verificationCodeStorageService,
25
28
_emailRepository = emailRepository,
29
+ _userAppSettingsRepository = userAppSettingsRepository,
30
+ _userContentPreferencesRepository = userContentPreferencesRepository,
26
31
_uuid = uuidGenerator;
27
32
28
33
final HtDataRepository <User > _userRepository;
29
34
final AuthTokenService _authTokenService;
30
35
final VerificationCodeStorageService _verificationCodeStorageService;
31
36
final HtEmailRepository _emailRepository;
37
+ final HtDataRepository <UserAppSettings > _userAppSettingsRepository;
38
+ final HtDataRepository <UserContentPreferences >
39
+ _userContentPreferencesRepository;
32
40
final Uuid _uuid;
33
41
34
42
/// Initiates the email sign-in process.
@@ -119,6 +127,16 @@ class AuthService {
119
127
);
120
128
user = await _userRepository.create (item: user); // Save the new user
121
129
print ('Created new user: ${user .id }' );
130
+
131
+ // Create default UserAppSettings for the new user
132
+ final defaultAppSettings = UserAppSettings (id: user.id);
133
+ await _userAppSettingsRepository.create (item: defaultAppSettings);
134
+ print ('Created default UserAppSettings for user: ${user .id }' );
135
+
136
+ // Create default UserContentPreferences for the new user
137
+ final defaultUserPreferences = UserContentPreferences (id: user.id);
138
+ await _userContentPreferencesRepository.create (item: defaultUserPreferences);
139
+ print ('Created default UserContentPreferences for user: ${user .id }' );
122
140
}
123
141
} on HtHttpException catch (e) {
124
142
print ('Error finding/creating user for $email : $e ' );
@@ -169,6 +187,16 @@ class AuthService {
169
187
);
170
188
}
171
189
190
+ // Create default UserAppSettings for the new anonymous user
191
+ final defaultAppSettings = UserAppSettings (id: user.id);
192
+ await _userAppSettingsRepository.create (item: defaultAppSettings);
193
+ print ('Created default UserAppSettings for anonymous user: ${user .id }' );
194
+
195
+ // Create default UserContentPreferences for the new anonymous user
196
+ final defaultUserPreferences = UserContentPreferences (id: user.id);
197
+ await _userContentPreferencesRepository.create (item: defaultUserPreferences);
198
+ print ('Created default UserContentPreferences for anonymous user: ${user .id }' );
199
+
172
200
// 2. Generate token
173
201
try {
174
202
final token = await _authTokenService.generateToken (user);
0 commit comments