signUpWithUsernameNPassword method
Implementation
@override
Future<Response<UserCredential>> signUpWithUsernameNPassword({
required String username,
required String password,
}) async {
final response = Response<UserCredential>();
var mail = AuthConverter.toMail(username, "user", "org");
if (AuthValidator.isValidEmail(mail)) {
try {
final result = await firebaseAuth.createUserWithEmailAndPassword(
email: mail ?? "example@user.org",
password: password,
);
return response.withData(result, message: "Sign up successful!");
} on FirebaseAuthException catch (_) {
return response.withException(_.message, status: Status.failure);
}
} else {
return response.withException("Username isn't valid!");
}
}