Merge branch '312-feature-integrate-google-maps-places-autocomplete-for-hub-address-validation' of https://github.com/Oloodi/krow-workforce into 312-feature-integrate-google-maps-places-autocomplete-for-hub-address-validation

This commit is contained in:
Achintha Isuru
2026-01-30 10:47:24 -05:00

View File

@@ -39,10 +39,9 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
return _getUserProfile( return _getUserProfile(
firebaseUserId: firebaseUser.uid, firebaseUserId: firebaseUser.uid,
fallbackEmail: firebaseUser.email ?? email, fallbackEmail: firebaseUser.email ?? email,
requireBusinessRole: true,
); );
//TO-DO: validate that user is business role and has business account
} on firebase.FirebaseAuthException catch (e) { } on firebase.FirebaseAuthException catch (e) {
if (e.code == 'invalid-credential' || e.code == 'wrong-password') { if (e.code == 'invalid-credential' || e.code == 'wrong-password') {
throw Exception('Incorrect email or password.'); throw Exception('Incorrect email or password.');
@@ -138,12 +137,18 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
Future<domain.User> _getUserProfile({ Future<domain.User> _getUserProfile({
required String firebaseUserId, required String firebaseUserId,
required String? fallbackEmail, required String? fallbackEmail,
bool requireBusinessRole = false,
}) async { }) async {
final QueryResult<dc.GetUserByIdData, dc.GetUserByIdVariables> response = await _dataConnect.getUserById(id: firebaseUserId).execute(); final QueryResult<dc.GetUserByIdData, dc.GetUserByIdVariables> response = await _dataConnect.getUserById(id: firebaseUserId).execute();
final dc.GetUserByIdUser? user = response.data?.user; final dc.GetUserByIdUser? user = response.data?.user;
if (user == null) { if (user == null) {
throw Exception('Authenticated user profile not found in database.'); throw Exception('Authenticated user profile not found in database.');
} }
if (requireBusinessRole && user.userRole != 'BUSINESS') {
await _firebaseAuth.signOut();
dc.ClientSessionStore.instance.clear();
throw Exception('User is not authorized for this app.');
}
final String? email = user.email ?? fallbackEmail; final String? email = user.email ?? fallbackEmail;
if (email == null || email.isEmpty) { if (email == null || email.isEmpty) {