session creation and show business information

This commit is contained in:
José Salazar
2026-01-22 18:17:24 -05:00
parent 9ddb0435ed
commit a70468ceb4
5 changed files with 127 additions and 17 deletions

View File

@@ -122,6 +122,7 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
Future<void> signOut() async {
try {
await _firebaseAuth.signOut();
dc.ClientSessionStore.instance.clear();
} catch (e) {
throw Exception('Error signing out: ${e.toString()}');
}
@@ -147,10 +148,36 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
throw Exception('User email is missing in profile data.');
}
return domain.User(
final domainUser = domain.User(
id: user.id,
email: email,
role: user.role.stringValue,
);
final businessResponse = await _dataConnect.getBusinessesByUserId(
userId: firebaseUserId,
).execute();
final business = businessResponse.data.businesses.isNotEmpty
? businessResponse.data.businesses.first
: null;
dc.ClientSessionStore.instance.setSession(
dc.ClientSession(
user: domainUser,
userPhotoUrl: user.photoUrl,
business: business == null
? null
: dc.ClientBusinessSession(
id: business.id,
businessName: business.businessName,
email: business.email,
city: business.city,
contactName: business.contactName,
companyLogoUrl: business.companyLogoUrl,
),
),
);
return domainUser;
}
}