login con email
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.example.prosappco">
|
package="com.example.prosappco">
|
||||||
<application
|
<application
|
||||||
android:label="prosappco"
|
android:label="prosapp"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
|
|||||||
@@ -75,14 +75,6 @@ class AuthenticationRepository extends GetxController {
|
|||||||
Future<void> createUserWithEmailAndPassword(
|
Future<void> createUserWithEmailAndPassword(
|
||||||
String email, String password) async {
|
String email, String password) async {
|
||||||
try {
|
try {
|
||||||
// try {
|
|
||||||
// await firebase.collection('Users').doc().set({
|
|
||||||
// "Email": email,
|
|
||||||
// "Password": password,
|
|
||||||
// });
|
|
||||||
// } catch (e) {
|
|
||||||
// print('Error $e');
|
|
||||||
// }
|
|
||||||
await _auth.createUserWithEmailAndPassword(
|
await _auth.createUserWithEmailAndPassword(
|
||||||
email: email, password: password);
|
email: email, password: password);
|
||||||
|
|
||||||
@@ -91,7 +83,11 @@ class AuthenticationRepository extends GetxController {
|
|||||||
: Get.to(LoginScreen());
|
: Get.to(LoginScreen());
|
||||||
} on FirebaseAuthException catch (e) {
|
} on FirebaseAuthException catch (e) {
|
||||||
final ex = SignUpWithEmailAndPasswordFailure.code(e.code);
|
final ex = SignUpWithEmailAndPasswordFailure.code(e.code);
|
||||||
print('FIREBASE AUTH EXCEPTION - ${ex.message}');
|
Get.snackbar(
|
||||||
|
'Correo Invalido',
|
||||||
|
'Por favor pruebe con otro.',
|
||||||
|
snackPosition: SnackPosition.BOTTOM,
|
||||||
|
);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
const ex = SignUpWithEmailAndPasswordFailure();
|
const ex = SignUpWithEmailAndPasswordFailure();
|
||||||
print('EXCEPTION - ${ex.message}');
|
print('EXCEPTION - ${ex.message}');
|
||||||
@@ -103,6 +99,27 @@ class AuthenticationRepository extends GetxController {
|
|||||||
try {
|
try {
|
||||||
await _auth.signInWithEmailAndPassword(email: email, password: password);
|
await _auth.signInWithEmailAndPassword(email: email, password: password);
|
||||||
} on FirebaseAuthException catch (e) {
|
} on FirebaseAuthException catch (e) {
|
||||||
|
if (e.code == 'wrong-password') {
|
||||||
|
Get.snackbar(
|
||||||
|
'Contraseña incorrecta',
|
||||||
|
'Por favor intentelo de nuevo.',
|
||||||
|
snackPosition: SnackPosition.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (e.code == 'invalid-email') {
|
||||||
|
Get.snackbar(
|
||||||
|
'Ingrese un email valido',
|
||||||
|
'Por favor pruebe con otro.',
|
||||||
|
snackPosition: SnackPosition.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (e.code == 'user-not-found') {
|
||||||
|
Get.snackbar(
|
||||||
|
'Email no encontrado',
|
||||||
|
'Este correo no se encuentra registrado.',
|
||||||
|
snackPosition: SnackPosition.BOTTOM,
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,9 @@ class LoginEmailController extends GetxController {
|
|||||||
|
|
||||||
final email = TextEditingController();
|
final email = TextEditingController();
|
||||||
final password = TextEditingController();
|
final password = TextEditingController();
|
||||||
|
|
||||||
|
void loginUser(String email, String password) {
|
||||||
|
AuthenticationRepository.instance
|
||||||
|
.loginWithEmailAndPassword(email, password);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,24 +96,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
|||||||
filled: true,
|
filled: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// child: TextFormField(
|
|
||||||
// controller: controller.phoneNo,
|
|
||||||
// decoration: InputDecoration(
|
|
||||||
// enabledBorder: OutlineInputBorder(
|
|
||||||
// borderSide: BorderSide(color: Color(0xFFECECEC)),
|
|
||||||
// borderRadius: BorderRadius.all(
|
|
||||||
// Radius.circular(50),
|
|
||||||
// )),
|
|
||||||
// focusedBorder: OutlineInputBorder(
|
|
||||||
// borderSide: BorderSide(color: Color(0xFFECECEC)),
|
|
||||||
// borderRadius: BorderRadius.all(
|
|
||||||
// Radius.circular(50),
|
|
||||||
// )),
|
|
||||||
// hintText: '+57',
|
|
||||||
// fillColor: Color.fromARGB(255, 239, 239, 239),
|
|
||||||
// filled: true,
|
|
||||||
// prefixIcon: Icon(Icons.phone_android_outlined)),
|
|
||||||
// ),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Padding(
|
const Padding(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:prosappco/main.dart';
|
|||||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||||
import 'package:prosappco/src/components/primary_btn.dart';
|
import 'package:prosappco/src/components/primary_btn.dart';
|
||||||
import 'package:prosappco/src/controllers/login_email_controller.dart';
|
import 'package:prosappco/src/controllers/login_email_controller.dart';
|
||||||
|
import 'package:prosappco/src/controllers/register_controller.dart';
|
||||||
import 'package:prosappco/src/screens/login.dart';
|
import 'package:prosappco/src/screens/login.dart';
|
||||||
import 'package:prosappco/src/screens/welcome.dart';
|
import 'package:prosappco/src/screens/welcome.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
@@ -216,7 +217,15 @@ class _LoginEmailScreenState extends State<LoginEmailScreen> {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 40),
|
padding: const EdgeInsets.only(bottom: 40),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: PrimaryButtom(onPressed: () {}, label: 'Iniciar'),
|
child: PrimaryButtom(
|
||||||
|
onPressed: () {
|
||||||
|
if (_formKey.currentState!.validate()) {
|
||||||
|
LoginEmailController.instance.loginUser(
|
||||||
|
controller.email.text.trim(),
|
||||||
|
controller.password.text.trim());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
label: 'Iniciar'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
RichText(
|
RichText(
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
|||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
backgroundColor: Color(0xFFD6F4FF),
|
backgroundColor: Color(0xFFD6F4FF),
|
||||||
body: Stack(
|
body: GestureDetector(
|
||||||
|
onTap: () => FocusScope.of(context).unfocus(),
|
||||||
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(top: 130),
|
margin: const EdgeInsets.only(top: 130),
|
||||||
@@ -145,7 +147,8 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
|||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: Text('Email',
|
child: Text('Email',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18.0, color: Color(0xFF65676B))),
|
fontSize: 18.0,
|
||||||
|
color: Color(0xFF65676B))),
|
||||||
)),
|
)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(bottom: 18),
|
padding: EdgeInsets.only(bottom: 18),
|
||||||
@@ -176,7 +179,8 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
|||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: Text('Password',
|
child: Text('Password',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18.0, color: Color(0xFF65676B))),
|
fontSize: 18.0,
|
||||||
|
color: Color(0xFF65676B))),
|
||||||
)),
|
)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 25),
|
padding: const EdgeInsets.only(bottom: 25),
|
||||||
@@ -264,6 +268,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user