diff --git a/apps/mobile/packages/features/staff/authentication/lib/src/data/repositories_impl/auth_repository_impl.dart b/apps/mobile/packages/features/staff/authentication/lib/src/data/repositories_impl/auth_repository_impl.dart index c620ebe3..ebb6f1c8 100644 --- a/apps/mobile/packages/features/staff/authentication/lib/src/data/repositories_impl/auth_repository_impl.dart +++ b/apps/mobile/packages/features/staff/authentication/lib/src/data/repositories_impl/auth_repository_impl.dart @@ -143,10 +143,6 @@ class AuthRepositoryImpl implements AuthRepositoryInterface { } final String email = user?.email ?? ''; - if (mode != AuthMode.signup && email.isEmpty) { - await firebaseAuth.signOut(); - throw Exception('User email is missing in profile data.'); - } //TO-DO: create(registration) user and staff account //TO-DO: save user data locally diff --git a/apps/mobile/packages/features/staff/profile_sections/finances/staff_bank_account/lib/src/data/repositories/bank_account_repository_impl.dart b/apps/mobile/packages/features/staff/profile_sections/finances/staff_bank_account/lib/src/data/repositories/bank_account_repository_impl.dart index abe63ddc..88c05730 100644 --- a/apps/mobile/packages/features/staff/profile_sections/finances/staff_bank_account/lib/src/data/repositories/bank_account_repository_impl.dart +++ b/apps/mobile/packages/features/staff/profile_sections/finances/staff_bank_account/lib/src/data/repositories/bank_account_repository_impl.dart @@ -19,72 +19,15 @@ class BankAccountRepositoryImpl implements BankAccountRepository { Future> getAccounts() async { final auth.User? user = firebaseAuth.currentUser; if (user == null) throw Exception('User not authenticated'); + final String? staffId = StaffSessionStore.instance.session?.staff?.id; + if (staffId == null || staffId.isEmpty) { + throw Exception('Staff profile is missing.'); + } - // return some mock data for now - return [ - BankAccount( - id: '1', - userId: user.uid, - bankName: 'Mock Bank', - accountNumber: '****1234', - accountName: 'My Checking Account', - type: BankAccountType.checking, - last4: '1234', - isPrimary: true, - ), - BankAccount( - id: '2', - userId: user.uid, - bankName: 'Mock Bank', - accountNumber: '****5678', - accountName: 'My Savings Account', - type: BankAccountType.savings, - last4: '5678', - isPrimary: false, - ), - BankAccount( - id: '3', - userId: user.uid, - bankName: 'Mock Bank', - accountNumber: '****1234', - accountName: 'My Checking Account', - type: BankAccountType.checking, - last4: '1234', - isPrimary: true, - ), - BankAccount( - id: '4', - userId: user.uid, - bankName: 'Mock Bank', - accountNumber: '****5678', - accountName: 'My Savings Account', - type: BankAccountType.savings, - last4: '5678', - isPrimary: false, - ), - BankAccount( - id: '5', - userId: user.uid, - bankName: 'Mock Bank', - accountNumber: '****1234', - accountName: 'My Checking Account', - type: BankAccountType.checking, - last4: '1234', - isPrimary: true, - ), - BankAccount( - id: '6', - userId: user.uid, - bankName: 'Mock Bank', - accountNumber: '****5678', - accountName: 'My Savings Account', - type: BankAccountType.savings, - last4: '5678', - isPrimary: false, - ), - ]; - - final QueryResult result = await dataConnect.getAccountsByOwnerId(ownerId: user.uid).execute(); + final QueryResult + result = await dataConnect + .getAccountsByOwnerId(ownerId: staffId) + .execute(); return result.data.accounts.map((GetAccountsByOwnerIdAccounts account) { return BankAccount( @@ -104,12 +47,16 @@ class BankAccountRepositoryImpl implements BankAccountRepository { Future addAccount(BankAccount account) async { final auth.User? user = firebaseAuth.currentUser; if (user == null) throw Exception('User not authenticated'); + final String? staffId = StaffSessionStore.instance.session?.staff?.id; + if (staffId == null || staffId.isEmpty) { + throw Exception('Staff profile is missing.'); + } await dataConnect.createAccount( bank: account.bankName, type: _mapDomainType(account.type), last4: account.last4 ?? account.accountNumber.substring(account.accountNumber.length - 4), - ownerId: user.uid, + ownerId: staffId, ).isPrimary(account.isPrimary).execute(); }