Skip to content

Commit

Permalink
Setup CI/CD for android build
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sneha-s committed Apr 5, 2024
1 parent 25f770a commit 1901c09
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/data/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@
"add_member_employee_exists_error": "Member already exists!",
"leave_already_applied_error_message": "Leave request has been already applied!",
"provide_required_information": "Please provide the required information to continue",
"apple_sign_in_error_message": "Oops! It looks like you haven't granted permission to access your email. Please check and grant permission to access your email address",

"sign_out_alert": "Are you sure you want to sign out?",

Expand Down
18 changes: 18 additions & 0 deletions lib/data/services/account_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ class AccountService {
return user;
}

Future<Account?> getAppleUser(firebase_auth.User authData) async {
final userDataDoc = await _accountsDb.doc(authData.uid).get();
final Account? userData = userDataDoc.data();
if (userData != null) {
await _setUserSession(authData.uid);
return userData;
} else if(authData.email != null ){
final user = Account(
uid: authData.uid,
email: authData.email!,
name: authData.displayName);
await _accountsDb.doc(authData.uid).set(user);
await _setUserSession(authData.uid);

return user;
}
}

Future<void> _setUserSession(String uid) async {
final Session? session = await deviceInfoProvider.getDeviceInfo();
if (session != null) {
Expand Down
9 changes: 7 additions & 2 deletions lib/ui/sign_in/bloc/sign_in_view_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,19 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {
emit(state.copyWith(appleSignInLoading: true));
firebase_auth.User? authUser = await _authService.signInWithApple();
if (authUser != null) {
final Account user = await _accountService.getUser(authUser);
final Account? user = await _accountService.getAppleUser(authUser);
if(user == null) {
emit(state.copyWith(
appleSignInLoading: false, error:"Please grant permission to access your email address"));
return;
}
await _userStateNotifier.setUser(user);
emit(state.copyWith(appleSignInLoading: false, signInSuccess: true));
} else {
emit(state.copyWith(appleSignInLoading: false));
}
} catch(e,stack) {
FirebaseCrashlytics.instance.recordError(e, stack);
FirebaseCrashlytics.instance.recordError(e, stack,reason: 'Apple Sign In Error');
emit(state.copyWith(
appleSignInLoading: false, error: somethingWentWrongError));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/sign_in/sign_in_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SignInScreenState extends State<SignInScreen> {
const SizedBox(
height: 20,
),
if (kIsWeb || Platform.isIOS) const AppleSignInButton()
if (!kIsWeb && Platform.isIOS) const AppleSignInButton()
],
),
),
Expand Down

0 comments on commit 1901c09

Please sign in to comment.