accessCodeRegisterWithEmailAndPassword method
Implementation
@override
Future<Either<AuthServiceSignInFailure, Unit>> accessCodeRegisterWithEmailAndPassword(
String email,
String password,
) async {
try {
var result = await authCallable.call({
'action': 'authRegisterWithEmailAndPasswordAndCode',
'email': email,
'password': password,
'accessCode': _accessCodeCached,
});
String token = result.data['token'];
logd('registerWithEmailAndPassword token: $token');
await retryIt(
() async => await _fbAuth.signInWithCustomToken(token),
maxAttempts: 8,
);
return right(unit);
// if (result.data['result'] == 'exists') {
// return left(const AuthServiceSignInFailure.userAlreadyExists());
// }
//TODO: I don' think the function actually returns any of these
} on FirebaseFunctionsException catch (e) {
logd('registerUserWithEmailAndPassword FirebaseFunctionsException: ${e.message}');
switch (e.message) {
case 'email-already-in-use':
return left(AuthServiceSignInFailure.userAlreadyExists);
case 'weak-password':
return left(AuthServiceSignInFailure.weakPassword);
case 'invalid-email':
return left(AuthServiceSignInFailure.invalidEmail);
default:
return left(AuthServiceSignInFailure.unexpected);
}
} catch (e) {
logd('registerUserWithEmailAndPassword other exception');
loge(e);
return left(AuthServiceSignInFailure.unexpected);
}
}