Skip to content

Commit

Permalink
refactor: renamed registrationWithEmail to registerOrInviteUser
Browse files Browse the repository at this point in the history
- it now accepts `UserSignupRequest` and returns `UserSignup?`
  • Loading branch information
adar2378 committed Sep 8, 2023
1 parent 5b0d05f commit 746a1c3
Showing 1 changed file with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,18 @@ class AuthCubit extends HydratedCubit<AuthState> {
);
}

Future<void> registrationWithEmail({
required String email,
required String firstName,
required String lastName,
/// Register or invite user to the system
Future<UserSignup?> registerOrInviteUser({
required UserSignupRequest userSignupRequest,
}) async =>
_authApiChecker(() async {
await authApi?.authSignupCreate(
signupRequest: SignupRequest(
email: email,
firstName: firstName,
lastName: lastName,
),
);
final result = (await authApi?.authUserCreate(
userSignupRequest: userSignupRequest,
))
?.data;

await requestOTP(email: email);
});
return result;
}) as UserSignup?;

Future<void> requestOTP({required String email}) async => _authApiChecker(
() async => (
Expand Down Expand Up @@ -139,10 +135,10 @@ class AuthCubit extends HydratedCubit<AuthState> {
}
});

Future<void> _authApiChecker(Function function) async {
Future<dynamic> _authApiChecker(Function function) async {
if (authApi == null) {
throw Exception('AuthApi is not initialized');
}
await function();
return await function();
}
}

0 comments on commit 746a1c3

Please sign in to comment.