Skip to content

Commit

Permalink
fix: email authenticator not removing properly (#585)
Browse files Browse the repository at this point in the history
## Description
<!-- Briefly explain the purpose of this PR and what it accomplishes.
-->

## Additional Notes
<!-- Add any extra context or relevant information here. -->

## Type of Change
- [x] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Refactoring
- [ ] Documentation
- [ ] Chore

## Screenshots (if applicable)
<!-- Include screenshots to demonstrate any UI changes. -->
<!-- <img width="180" alt="image" src="image_url_here"> -->
  • Loading branch information
ice-ajax authored Jan 21, 2025
1 parent 29c72ca commit 543e207
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class StoryContent extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final postReference = useRef(EventReference.fromIonConnectEntity(post));
final emojiState = ref.watch(emojiReactionsControllerProvider);
final textController = useTextEditingController();
final isKeyboardVisible = KeyboardVisibilityProvider.isKeyboardVisible(context);
final canReply = ref.watch(canReplyProvider(postReference.value)).valueOrNull ?? false;
final postReference = EventReference.fromIonConnectEntity(post);
final canReply = ref.watch(canReplyProvider(postReference)).valueOrNull ?? false;

useOnInit(
() => ref.read(storyPauseControllerProvider.notifier).paused = isKeyboardVisible,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import 'package:ion/app/features/auth/views/pages/recover_user_twofa_page/compon
import 'package:ion/app/features/auth/views/pages/recover_user_twofa_page/components/twofa_try_again_page.dart';
import 'package:ion/app/features/components/verify_identity/verify_identity_prompt_dialog_helper.dart';
import 'package:ion/app/features/protect_account/authenticator/data/adapter/twofa_type_adapter.dart';
import 'package:ion/app/features/protect_account/email/providers/linked_email_provider.c.dart';
import 'package:ion/app/features/protect_account/email/providers/linked_phone_provider.c.dart';
import 'package:ion/app/features/protect_account/secure_account/providers/delete_twofa_notifier.c.dart';
import 'package:ion/app/features/protect_account/secure_account/providers/request_twofa_code_notifier.c.dart';
import 'package:ion/app/router/utils/show_simple_bottom_sheet.dart';
Expand Down Expand Up @@ -127,9 +129,12 @@ class DeleteTwoFAInputStep extends HookConsumerWidget {
ref.context,
(child) => RiverpodVerifyIdentityRequestBuilder(
provider: deleteTwoFANotifierProvider,
requestWithVerifyIdentity: (OnVerifyIdentity<GenerateSignatureResponse> onVerifyIdentity) {
ref.read(deleteTwoFANotifierProvider.notifier).deleteTwoFa(
TwoFaTypeAdapter(twoFaToDelete).twoFAType,
requestWithVerifyIdentity: (
OnVerifyIdentity<GenerateSignatureResponse> onVerifyIdentity,
) async {
final twoFaValue = await _getTwoFaValue(ref, twoFaToDelete);
await ref.read(deleteTwoFANotifierProvider.notifier).deleteTwoFa(
TwoFaTypeAdapter(twoFaToDelete, twoFaValue).twoFAType,
onVerifyIdentity,
[
for (final controller in controllers.entries)
Expand Down Expand Up @@ -163,4 +168,12 @@ class DeleteTwoFAInputStep extends HookConsumerWidget {
}
});
}

Future<String?> _getTwoFaValue(WidgetRef ref, TwoFaType type) async {
return switch (type) {
TwoFaType.email => ref.read(linkedEmailProvider.future),
TwoFaType.sms => ref.read(linkedPhoneProvider.future),
TwoFaType.auth => null,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import 'package:collection/collection.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:ion/app/features/protect_account/secure_account/providers/user_details_provider.c.dart';
import 'package:ion/app/utils/formatters.dart';
import 'package:ion/app/utils/predicates.dart';
import 'package:ion_identity_client/ion_identity.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
Expand All @@ -29,5 +28,5 @@ Future<String> linkedEmail(Ref ref) async {
0;

final email = emails[emailIndex];
return shortenEmail(email);
return email;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import 'package:collection/collection.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:ion/app/features/protect_account/secure_account/providers/user_details_provider.c.dart';
import 'package:ion/app/utils/formatters.dart';
import 'package:ion/app/utils/predicates.dart';
import 'package:ion_identity_client/ion_identity.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
Expand All @@ -30,5 +29,5 @@ Future<String> linkedPhone(Ref ref) async {

final phone = phones[phoneIndex];

return shortenPhoneNumber(phone);
return phone;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:ion/app/extensions/extensions.dart';
import 'package:ion/app/features/auth/views/components/auth_scrolled_body/auth_header_icon.dart';
import 'package:ion/app/features/protect_account/components/delete_twofa_initial_scaffold.dart';
import 'package:ion/app/features/protect_account/email/providers/linked_email_provider.c.dart';
import 'package:ion/app/utils/formatters.dart';
import 'package:ion/generated/assets.gen.dart';

class DeleteEmailInitialStep extends StatelessWidget {
Expand Down Expand Up @@ -46,7 +47,8 @@ class _LinkedEmail extends ConsumerWidget {
final locale = context.i18n;
final colors = context.theme.appColors;

final linkedEmail = ref.watch(linkedEmailProvider).valueOrNull ?? '';
final linkedEmail = ref.watch(linkedEmailProvider).valueOrNull;
final shortenedEmail = linkedEmail != null ? shortenEmail(linkedEmail) : '';

return Column(
children: [
Expand All @@ -58,7 +60,7 @@ class _LinkedEmail extends ConsumerWidget {
),
SizedBox(height: 8.0.s),
Text(
linkedEmail,
shortenedEmail,
style: context.theme.appTextThemes.subtitle.copyWith(
color: colors.primaryText,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:ion/app/extensions/extensions.dart';
import 'package:ion/app/features/auth/views/components/auth_scrolled_body/auth_header_icon.dart';
import 'package:ion/app/features/protect_account/components/delete_twofa_initial_scaffold.dart';
import 'package:ion/app/features/protect_account/email/providers/linked_phone_provider.c.dart';
import 'package:ion/app/utils/formatters.dart';
import 'package:ion/generated/assets.gen.dart';

class DeletePhoneInitialStep extends StatelessWidget {
Expand Down Expand Up @@ -43,7 +44,8 @@ class _LinkedPhone extends ConsumerWidget {
final locale = context.i18n;
final colors = context.theme.appColors;

final linkedPhone = ref.watch(linkedPhoneProvider).valueOrNull ?? '';
final linkedPhone = ref.watch(linkedPhoneProvider).valueOrNull;
final shortenedPhone = linkedPhone != null ? shortenPhoneNumber(linkedPhone) : '';

return Column(
children: [
Expand All @@ -58,7 +60,7 @@ class _LinkedPhone extends ConsumerWidget {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
linkedPhone,
shortenedPhone,
style: context.theme.appTextThemes.subtitle.copyWith(
color: colors.primaryText,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ class TwoFADataSource {
(e) => '$queryOption=${e.option}&$queryValue=${e.value!}',
)
.join('&');
final twoFaValue = twoFAType.value ?? 0;
final uri = Uri.parse(networkClient.dio.options.baseUrl)
.resolveUri(
Uri(
path: sprintf(deleteTwoFaPath, [userId, twoFAType.option, 0]),
path: sprintf(deleteTwoFaPath, [userId, twoFAType.option, twoFaValue]),
query: query,
),
)
Expand Down

0 comments on commit 543e207

Please sign in to comment.