login con email
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.prosappco">
|
||||
<application
|
||||
android:label="prosappco"
|
||||
android:label="prosapp"
|
||||
android:name="${applicationName}"
|
||||
android:icon="@mipmap/ic_launcher">
|
||||
<activity
|
||||
|
||||
@@ -75,14 +75,6 @@ class AuthenticationRepository extends GetxController {
|
||||
Future<void> createUserWithEmailAndPassword(
|
||||
String email, String password) async {
|
||||
try {
|
||||
// try {
|
||||
// await firebase.collection('Users').doc().set({
|
||||
// "Email": email,
|
||||
// "Password": password,
|
||||
// });
|
||||
// } catch (e) {
|
||||
// print('Error $e');
|
||||
// }
|
||||
await _auth.createUserWithEmailAndPassword(
|
||||
email: email, password: password);
|
||||
|
||||
@@ -91,7 +83,11 @@ class AuthenticationRepository extends GetxController {
|
||||
: Get.to(LoginScreen());
|
||||
} on FirebaseAuthException catch (e) {
|
||||
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 (_) {
|
||||
const ex = SignUpWithEmailAndPasswordFailure();
|
||||
print('EXCEPTION - ${ex.message}');
|
||||
@@ -103,6 +99,27 @@ class AuthenticationRepository extends GetxController {
|
||||
try {
|
||||
await _auth.signInWithEmailAndPassword(email: email, password: password);
|
||||
} 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 (_) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,4 +7,9 @@ class LoginEmailController extends GetxController {
|
||||
|
||||
final email = 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,
|
||||
),
|
||||
),
|
||||
// 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(
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:prosappco/main.dart';
|
||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||
import 'package:prosappco/src/components/primary_btn.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/welcome.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -216,7 +217,15 @@ class _LoginEmailScreenState extends State<LoginEmailScreen> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 40),
|
||||
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(
|
||||
|
||||
@@ -28,7 +28,9 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: Color(0xFFD6F4FF),
|
||||
body: Stack(
|
||||
body: GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 130),
|
||||
@@ -145,7 +147,8 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text('Email',
|
||||
style: TextStyle(
|
||||
fontSize: 18.0, color: Color(0xFF65676B))),
|
||||
fontSize: 18.0,
|
||||
color: Color(0xFF65676B))),
|
||||
)),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 18),
|
||||
@@ -176,7 +179,8 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
alignment: Alignment.topLeft,
|
||||
child: Text('Password',
|
||||
style: TextStyle(
|
||||
fontSize: 18.0, color: Color(0xFF65676B))),
|
||||
fontSize: 18.0,
|
||||
color: Color(0xFF65676B))),
|
||||
)),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 25),
|
||||
@@ -264,6 +268,7 @@ class _RegisterScreenState extends State<RegisterScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user