Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 add tests in auth #3

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/app/app_module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import 'shared/service/repository.dart';
class AppModule extends MainModule {
@override
List<Bind> get binds => [
Bind((i) => FirebaseAuth.instance),
Bind((i) => FirebaseFirestore.instance),
Bind((i) => Repository(client: i())),
Bind((i) => FoodPromiseController()),
Bind<FirebaseAuth>((i) => FirebaseAuth.instance),
Bind<FirebaseFirestore>((i) => FirebaseFirestore.instance),
Bind<Repository>((i) => Repository(client: i())),
Bind<FoodPromiseController>((i) => FoodPromiseController()),
];

@override
Expand Down
8 changes: 4 additions & 4 deletions lib/app/modules/auth/presenter/login/login_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LoginController extends GetxController {
inputs[1]['controller'] = textEditingControllerPass;
}

Future<bool> _signInFunction() async {
Future<bool> signInFunction() async {
loading.value = true;
final auth = Modular.get<FirebaseAuth>();

Expand Down Expand Up @@ -71,8 +71,8 @@ class LoginController extends GetxController {
return false;
}

void _onSignInPressed() async {
final success = await _signInFunction();
void onSignInPressed() async {
final success = await signInFunction();

if (success) {
print('Sign in success');
Expand All @@ -83,7 +83,7 @@ class LoginController extends GetxController {
}

void login() {
if (formKey.currentState.validate()) _onSignInPressed();
if (formKey.currentState.validate()) onSignInPressed();
}

void close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RegisterController extends GetxController {
inputs[3]['controller'] = textEditingControllerRePass;
}

Future<bool> _signUpFunction() async {
Future<bool> signUpFunction() async {
loading.value = true;
final auth = Modular.get<FirebaseAuth>();

Expand All @@ -66,6 +66,7 @@ class RegisterController extends GetxController {
if (rePassword == password) {
final userCredential = await auth.createUserWithEmailAndPassword(
email: email, password: password);

final uid = userCredential.user.uid;

final repository = Modular.get<Repository>();
Expand Down Expand Up @@ -101,8 +102,8 @@ class RegisterController extends GetxController {
return false;
}

void _onSignUpPressed() async {
final success = await _signUpFunction();
void onSignUpPressed() async {
final success = await signUpFunction();

if (success) {
print('Sign Up');
Expand All @@ -113,7 +114,7 @@ class RegisterController extends GetxController {
}

void register() {
if (formKey.currentState.validate()) _onSignUpPressed();
if (formKey.currentState.validate()) onSignUpPressed();
}

void close() {
Expand Down
Loading