Implemented home management and user invitation flows

This commit is contained in:
Abdullah Alassaf
2024-06-05 03:42:00 +03:00
parent 6a9c2967d2
commit 631ba53d7a
29 changed files with 968 additions and 288 deletions
+9 -2
View File
@@ -1,4 +1,3 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
@@ -9,6 +8,7 @@ import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/navigation/navigation_service.dart';
import 'package:syncrow_app/navigation/routing_constants.dart';
import 'package:syncrow_app/services/api/authentication_api.dart';
import 'package:syncrow_app/utils/helpers/snack_bar.dart';
part 'auth_state.dart';
class AuthCubit extends Cubit<AuthState> {
@@ -26,6 +26,7 @@ class AuthCubit extends Cubit<AuthState> {
final loginFormKey = GlobalKey<FormState>();
final signUpFormKey = GlobalKey<FormState>();
bool isPasswordVisible = false;
bool showValidationMessage = false;
static GlobalKey<FormState> formKey = GlobalKey<FormState>();
@@ -58,7 +59,7 @@ class AuthCubit extends Cubit<AuthState> {
if (value.isNotEmpty) {
if (!RegExp(r'^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$')
.hasMatch(value)) {
return 'Password must contain at least one uppercase letter, one lowercase letter, one number and one special character';
return 'Password must contain at least:\n - one uppercase letter.\n - one lowercase letter.\n - one number. \n - special character';
}
}
}
@@ -147,6 +148,12 @@ class AuthCubit extends Cubit<AuthState> {
login() async {
emit(AuthLoginLoading());
try {
if (emailController.text.isEmpty || passwordController.text.isEmpty) {
CustomSnackBar.displaySnackBar('Please enter your credentials');
emit(AuthLoginError(message: 'Something went wrong'));
return;
}
token = await AuthenticationAPI.loginWithEmail(
model: LoginWithEmailModel(
email: emailController.text.toLowerCase(),