Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: fix intruder john and registration break off (KIDS-1324) #1068

Merged
merged 3 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/features/auth/cubit/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class AuthCubit extends Cubit<AuthState> {
}
}

Future<void> refreshUser({bool emitAuthentication = true}) async {
Future<void> refreshUser({bool emitAuthentication = true, bool forceAuthUpdate = false}) async {
if (emitAuthentication) emit(state.copyWith(status: AuthStatus.loading));
try {
final userExt = await _authRepositoy.fetchUserExtension(state.user.guid);
Expand All @@ -344,6 +344,7 @@ class AuthCubit extends Cubit<AuthState> {
),
);
}
_authRepositoy.updateSessionStream(true, force: forceAuthUpdate);
} catch (e, stackTrace) {
LoggingInfo.instance.error(
e.toString(),
Expand Down
6 changes: 3 additions & 3 deletions lib/features/auth/repositories/auth_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mixin AuthRepository {
required String notificationId,
});

void updateSessionStream(bool hasSession);
void updateSessionStream(bool hasSession, {bool force = false});

Stream<bool> hasSessionStream();

Expand Down Expand Up @@ -580,8 +580,8 @@ class AuthRepositoyImpl with AuthRepository {
}

@override
void updateSessionStream(bool hasSession) {
if (_hasSession != hasSession) {
void updateSessionStream(bool hasSession, {bool force = false}) {
if (force || _hasSession != hasSession) {
_hasSession = hasSession;
_hasSessionStreamController.add(hasSession);
}
Expand Down
49 changes: 28 additions & 21 deletions lib/features/family/features/profiles/cubit/profiles_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,27 +144,34 @@ class ProfilesCubit extends Cubit<ProfilesState> {
List<Profile> newProfiles,
List<Member> members,
) async {
UserExt? userExternal;
final (userExt, session, amountPresets) =
await _authRepository.isAuthenticated() ?? (null, null, null);
userExternal = userExt;

if (userExternal?.needRegistration ?? false) {
emit(
ProfilesNeedsRegistration(
profiles: newProfiles,
activeProfileIndex: state.activeProfileIndex,
hasFamily:
newProfiles.where((p) => p.type.contains('Child')).isNotEmpty,
),
);
} else if (newProfiles.length <= 1) {
emit(
ProfilesNotSetupState(
profiles: newProfiles,
activeProfileIndex: state.activeProfileIndex,
cachedMembers: members,
),
try {
UserExt? userExternal;
final (userExt, session, amountPresets) =
await _authRepository.isAuthenticated() ?? (null, null, null);
userExternal = userExt;

if (userExternal?.needRegistration ?? false) {
emit(
ProfilesNeedsRegistration(
profiles: newProfiles,
activeProfileIndex: state.activeProfileIndex,
hasFamily:
newProfiles.where((p) => p.type.contains('Child')).isNotEmpty,
),
);
} else if (newProfiles.length <= 1) {
emit(
ProfilesNotSetupState(
profiles: newProfiles,
activeProfileIndex: state.activeProfileIndex,
cachedMembers: members,
),
);
}
} catch (e,s) {
LoggingInfo.instance.logExceptionForDebug(
e,
stacktrace: s,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import 'package:givt_app/features/family/shared/design/components/components.dar
import 'package:givt_app/features/family/shared/widgets/loading/custom_progress_indicator.dart';
import 'package:givt_app/features/family/utils/utils.dart';
import 'package:givt_app/features/impact_groups/widgets/impact_group_recieve_invite_sheet.dart';
import 'package:givt_app/features/registration/bloc/registration_bloc.dart';
import 'package:givt_app/shared/models/analytics_event.dart';
import 'package:givt_app/shared/models/user_ext.dart';
import 'package:givt_app/shared/widgets/fun_scaffold.dart';
Expand Down Expand Up @@ -100,6 +101,14 @@ class _ProfileSelectionScreenState extends State<ProfileSelectionScreen> {
} else {
await AddMemberUtil.addMemberPushPages(context);
}
} else if (state is ProfilesNeedsRegistration) {
if (context.read<RegistrationBloc>().state.status ==
RegistrationStatus.createStripeAccount) {
context.pushNamed(
FamilyPages.creditCardDetails.name,
extra: context.read<RegistrationBloc>(),
);
}
}
},
listenWhen: (previous, current) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/features/registration/bloc/registration_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class RegistrationBloc extends Bloc<RegistrationEvent, RegistrationState> {
isNewUser: false,
);

await authCubit.refreshUser();
await authCubit.refreshUser(forceAuthUpdate: true);
if (event.country.toUpperCase() == Country.us.countryCode) {
emit(
state.copyWith(
Expand Down
57 changes: 25 additions & 32 deletions lib/features/registration/pages/registration_success_us.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:givt_app/features/registration/widgets/registered_check_animatio
import 'package:givt_app/l10n/l10n.dart';
import 'package:givt_app/shared/models/analytics_event.dart';
import 'package:givt_app/shared/widgets/fun_scaffold.dart';
import 'package:givt_app/utils/app_theme.dart';
import 'package:go_router/go_router.dart';

class RegistrationSuccessUs extends StatelessWidget {
Expand All @@ -18,38 +17,32 @@ class RegistrationSuccessUs extends StatelessWidget {

@override
Widget build(BuildContext context) {
return PopScope(
onPopInvoked: (didPop) =>
context.goNamed(FamilyPages.profileSelection.name),
child: Theme(
data: AppTheme.lightTheme,
child: FunScaffold(
appBar: FunTopAppBar.primary99(
title: 'Registration complete',
),
body: Center(
child: Column(
children: [
const Spacer(),
const RegisteredCheckAnimation(),
const Spacer(),
FunButton(
text: context.l10n.setUpFamily,
onTap: () {
context.pushReplacementNamed(
FamilyPages.profileSelection.name,
);
},
analyticsEvent: AnalyticsEvent(
AmplitudeEvents.registrationSuccesButtonClicked,
parameters: {
'id': context.read<AuthCubit>().state.user.guid,
},
),
),
],
return FunScaffold(
appBar: FunTopAppBar.primary99(
title: 'Registration complete',
),
canPop: false,
body: Center(
child: Column(
children: [
const Spacer(),
const RegisteredCheckAnimation(),
const Spacer(),
FunButton(
text: context.l10n.setUpFamily,
onTap: () {
context.pushReplacementNamed(
FamilyPages.profileSelection.name,
);
},
analyticsEvent: AnalyticsEvent(
AmplitudeEvents.registrationSuccesButtonClicked,
parameters: {
'id': context.read<AuthCubit>().state.user.guid,
},
),
),
),
],
),
),
);
Expand Down
1 change: 1 addition & 0 deletions lib/features/registration/pages/us_signup_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class _UsSignUpPageState extends State<UsSignUpPage> {
},
builder: (context, state) {
return FunScaffold(
canPop: false,
appBar: FunTopAppBar.primary99(
leading: GenerosityBackButton(
onPressed: () {
Expand Down