Skip to content

Commit

Permalink
feat: added local authentication on the application
Browse files Browse the repository at this point in the history
  • Loading branch information
IamMuuo committed Dec 16, 2024
1 parent f806cdf commit 9575f6d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/features/auth/cubit/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:academia/features/auth/cubit/auth_states.dart';
import 'package:connectivity_plus/connectivity_plus.dart';

/// TODO: erick figure out a way to automatically log in user when connection is established
class AuthCubit extends Cubit<AuthState> {
final UserRepository _userRepository = UserRepository();

Expand All @@ -25,7 +26,14 @@ class AuthCubit extends Cubit<AuthState> {
result.fold((error) {
emit(AuthErrorState(error));
return;
}, (creds) {
}, (creds) async {
final List<ConnectivityResult> connectivityResult =
await (Connectivity().checkConnectivity());
// Authenticate locally if no internet connection was found
if (connectivityResult.contains(ConnectivityResult.none)) {
emit(AuthenticatedState(user: users.first, localAuth: true));
return;
}
authenticate(creds).then((auth) {
auth.fold((error) {
emit(AuthErrorState(error));
Expand Down

0 comments on commit 9575f6d

Please sign in to comment.