feat: Refactor StaffSession to remove user field and update related session handling

This commit is contained in:
Achintha Isuru
2026-02-17 16:31:23 -05:00
parent 61be898609
commit a119f36e41
4 changed files with 43 additions and 13 deletions

View File

@@ -239,7 +239,6 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
);
StaffSessionStore.instance.setSession(
StaffSession(
user: domainUser,
staff: domainStaff,
ownerId: staffRecord?.ownerId,
),

View File

@@ -22,19 +22,17 @@ class ProfileSetupRepositoryImpl implements ProfileSetupRepository {
final auth.User? firebaseUser = _service.auth.currentUser;
if (firebaseUser == null) {
throw const NotAuthenticatedException(
technicalMessage: 'User not authenticated.');
technicalMessage: 'User not authenticated.',
);
}
final StaffSession? session = StaffSessionStore.instance.session;
final String email = session?.user.email ?? '';
final String email = session?.staff?.email ?? '';
final String? phone = firebaseUser.phoneNumber;
final fdc.OperationResult<CreateStaffData, CreateStaffVariables> result =
await _service.connector
.createStaff(
userId: firebaseUser.uid,
fullName: fullName,
)
.createStaff(userId: firebaseUser.uid, fullName: fullName)
.bio(bio)
.preferredLocations(preferredLocations)
.maxDistanceMiles(maxDistanceMiles.toInt())
@@ -45,7 +43,7 @@ class ProfileSetupRepositoryImpl implements ProfileSetupRepository {
.execute();
final String staffId = result.data.staff_insert.id;
final Staff staff = Staff(
id: staffId,
authProviderId: firebaseUser.uid,
@@ -54,10 +52,10 @@ class ProfileSetupRepositoryImpl implements ProfileSetupRepository {
phone: phone,
status: StaffStatus.completedProfile,
);
if (session != null) {
StaffSessionStore.instance.setSession(
StaffSession(user: session.user, staff: staff, ownerId: session.ownerId),
StaffSession(staff: staff, ownerId: session.ownerId),
);
}
});