Skip to content

Commit

Permalink
Allow user to add email (#96)
Browse files Browse the repository at this point in the history
* Allow user to add email

* Update ruby version
  • Loading branch information
cp-sneha-s authored Apr 8, 2024
1 parent 702cffe commit 7f6d9a5
Show file tree
Hide file tree
Showing 20 changed files with 712 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up ruby env
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.2
ruby-version: 3.3.0
bundler-cache: true

- name: Retrieve the secret and decode it to a file
Expand Down
15 changes: 14 additions & 1 deletion lib/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:projectunity/ui/admin/forms/form_list/form_list_screen.dart';
import 'package:projectunity/ui/admin/leaves/leave_screen/admin_leaves_screen.dart';
import 'package:projectunity/ui/shared/dashboard/navigation_item.dart';
import 'package:projectunity/ui/shared/profile/view_profile/view_profle_screen.dart';
import 'package:projectunity/ui/sign_in/setup_profile/setup_profile_screen.dart';
import 'package:projectunity/ui/sign_in/sign_in_screen.dart';
import 'package:projectunity/ui/user/leaves/detail/user_leave_detail_screen.dart';
import 'package:projectunity/ui/user/leaves/leaves_screen/user_leave_screen.dart';
Expand All @@ -30,6 +31,7 @@ import 'ui/user/leaves/apply_leave/apply_leave_screen.dart';
import 'ui/user/members/detail/user_employee_detail_screen.dart';
import 'ui/user/members/members_screen/user_members_screen.dart';
import 'ui/widget/error/page_not_found_screen.dart';
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;

@Injectable()
class AppRouter {
Expand Down Expand Up @@ -57,6 +59,15 @@ class AppRouter {
: Routes.userHome,
navigatorKey: _rootNavigatorKey,
routes: [
GoRoute(
parentNavigatorKey: _rootNavigatorKey,
path: Routes.setupProfile,
name: Routes.setupProfile,
pageBuilder: (context, state) {
final firebase_auth.User user =
state.extra as firebase_auth.User;
return CupertinoPage(child: SetUpProfilePage(user: user));
}),
GoRoute(
parentNavigatorKey: _rootNavigatorKey,
path: Routes.login,
Expand Down Expand Up @@ -370,8 +381,9 @@ class AppRouter {
redirect: (context, GoRouterState state) {
final location = state.matchedLocation;
final loggingIn = location == Routes.login;
final setupProfile = location == Routes.setupProfile;
if (_userManager.state == UserState.unauthenticated) {
return loggingIn ? null : Routes.login;
return loggingIn || setupProfile ? null : Routes.login;
}
if (_userManager.state == UserState.authenticated &&
!location.contains(Routes.joinSpace)) {
Expand Down Expand Up @@ -410,6 +422,7 @@ abstract class Routes {
static const login = '/login';
static const joinSpace = '/spaces';
static const createSpace = 'create-space';
static const setupProfile = '/setup-profile';

static const adminHome = '/admin/home';
static const inviteMember = 'invite';
Expand Down
146 changes: 76 additions & 70 deletions lib/data/di/service_locator.config.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/data/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@
"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?",
"setup_profile_title": "Setup Profile",
"submit_button_tag": "Submit",

"deactivate_user_account_alert": "Are you sure you want to deactivate {username}'s account? This action cannot be undone.",
"@deactivate_user_account_alert": {
Expand Down
5 changes: 5 additions & 0 deletions lib/data/services/account_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ class AccountService {
return null;
}

Future<void> setUserAccount(Account user) async {
await _accountsDb.doc(user.uid).set(user);
await _setUserSession(user.uid);
}

Future<void> _setUserSession(String uid) async {
final Session? session = await deviceInfoProvider.getDeviceInfo();
if (session != null) {
Expand Down
1 change: 0 additions & 1 deletion lib/data/services/auth_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class AuthService {
credential = await firebase_auth.FirebaseAuth.instance
.signInWithProvider(appleProvider);
}

return credential.user;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/ui/sign_in/bloc/sign_in_view_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {
final Account? user = await _accountService.getAppleUser(authUser);
if (user == null) {
emit(state.copyWith(
appleSignInLoading: false, error: appleSigninError));
appleSignInLoading: false,
error: appleSigninError,
firebaseAuthUser: authUser));
return;
}
await _userStateNotifier.setUser(user);
Expand Down
1 change: 1 addition & 0 deletions lib/ui/sign_in/bloc/sign_in_view_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ class SignInState with _$SignInState {
@Default(false) googleSignInLoading,
@Default(false) appleSignInLoading,
@Default(false) signInSuccess,
Object? firebaseAuthUser,
String? error}) = _SignInState;
}
Loading

0 comments on commit 7f6d9a5

Please sign in to comment.