Remove SMS autofill feature for android
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
import 'package:form_builder_validators/form_builder_validators.dart';
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||||
import 'package:alt_sms_autofill/alt_sms_autofill.dart';
|
|
||||||
import 'package:thingsboard_app/core/auth/login/login_page_background.dart';
|
import 'package:thingsboard_app/core/auth/login/login_page_background.dart';
|
||||||
import 'package:thingsboard_app/core/context/tb_context.dart';
|
import 'package:thingsboard_app/core/context/tb_context.dart';
|
||||||
import 'package:thingsboard_app/core/context/tb_context_widget.dart';
|
import 'package:thingsboard_app/core/context/tb_context_widget.dart';
|
||||||
@@ -66,8 +65,6 @@ class TwoFactorAuthenticationPage extends TbPageWidget {
|
|||||||
|
|
||||||
class _TwoFactorAuthenticationPageState
|
class _TwoFactorAuthenticationPageState
|
||||||
extends TbPageState<TwoFactorAuthenticationPage> {
|
extends TbPageState<TwoFactorAuthenticationPage> {
|
||||||
static RegExp smsCodeRegExp = new RegExp(r"(\d{6})");
|
|
||||||
|
|
||||||
final _twoFactorAuthFormKey = GlobalKey<FormBuilderState>();
|
final _twoFactorAuthFormKey = GlobalKey<FormBuilderState>();
|
||||||
ValueNotifier<TwoFaProviderType?> _selectedProvider =
|
ValueNotifier<TwoFaProviderType?> _selectedProvider =
|
||||||
ValueNotifier<TwoFaProviderType?>(null);
|
ValueNotifier<TwoFaProviderType?>(null);
|
||||||
@@ -80,7 +77,6 @@ class _TwoFactorAuthenticationPageState
|
|||||||
Timer? _timer;
|
Timer? _timer;
|
||||||
Timer? _tooManyRequestsTimer;
|
Timer? _tooManyRequestsTimer;
|
||||||
ValueNotifier<int> _countDownTime = ValueNotifier<int>(0);
|
ValueNotifier<int> _countDownTime = ValueNotifier<int>(0);
|
||||||
bool _listenForSms = false;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -101,9 +97,6 @@ class _TwoFactorAuthenticationPageState
|
|||||||
if (this._selectedProvider.value != TwoFaProviderType.TOTP) {
|
if (this._selectedProvider.value != TwoFaProviderType.TOTP) {
|
||||||
_sendCode();
|
_sendCode();
|
||||||
_showResendAction.value = true;
|
_showResendAction.value = true;
|
||||||
if (this._selectedProvider.value == TwoFaProviderType.SMS) {
|
|
||||||
_startListenForSmsCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_timer = Timer.periodic(Duration(seconds: 1), (timer) {
|
_timer = Timer.periodic(Duration(seconds: 1), (timer) {
|
||||||
_updatedTime();
|
_updatedTime();
|
||||||
@@ -118,7 +111,6 @@ class _TwoFactorAuthenticationPageState
|
|||||||
if (_tooManyRequestsTimer != null) {
|
if (_tooManyRequestsTimer != null) {
|
||||||
_tooManyRequestsTimer!.cancel();
|
_tooManyRequestsTimer!.cancel();
|
||||||
}
|
}
|
||||||
_cancelSmsCodeListen();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,39 +370,6 @@ class _TwoFactorAuthenticationPageState
|
|||||||
labelText: providerFormData.placeholderFunction(context)));
|
labelText: providerFormData.placeholderFunction(context)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _startListenForSmsCode() async {
|
|
||||||
_listenForSms = true;
|
|
||||||
_listenForSmsCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _listenForSmsCode() async {
|
|
||||||
String? comingSms;
|
|
||||||
try {
|
|
||||||
comingSms = await AltSmsAutofill().listenForSms;
|
|
||||||
} catch (e) {
|
|
||||||
_listenForSms = false;
|
|
||||||
comingSms = null;
|
|
||||||
}
|
|
||||||
if (comingSms != null) {
|
|
||||||
RegExpMatch? match = smsCodeRegExp.firstMatch(comingSms);
|
|
||||||
if (match != null) {
|
|
||||||
String? codeStr = match.group(1);
|
|
||||||
if (codeStr != null) {
|
|
||||||
_twoFactorAuthFormKey.currentState
|
|
||||||
?.patchValue({'verificationCode': codeStr});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (_listenForSms) {
|
|
||||||
_listenForSmsCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _cancelSmsCodeListen() async {
|
|
||||||
_listenForSms = false;
|
|
||||||
AltSmsAutofill().unregisterListener();
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _sendVerificationCode(BuildContext context) async {
|
Future<void> _sendVerificationCode(BuildContext context) async {
|
||||||
FocusScope.of(context).unfocus();
|
FocusScope.of(context).unfocus();
|
||||||
if (_twoFactorAuthFormKey.currentState?.saveAndValidate() ?? false) {
|
if (_twoFactorAuthFormKey.currentState?.saveAndValidate() ?? false) {
|
||||||
@@ -451,7 +410,6 @@ class _TwoFactorAuthenticationPageState
|
|||||||
_prevProvider = type == null ? _selectedProvider.value : null;
|
_prevProvider = type == null ? _selectedProvider.value : null;
|
||||||
_selectedProvider.value = type;
|
_selectedProvider.value = type;
|
||||||
_showResendAction.value = false;
|
_showResendAction.value = false;
|
||||||
await _cancelSmsCodeListen();
|
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
var providersInfo = tbContext.twoFactorAuthProviders;
|
var providersInfo = tbContext.twoFactorAuthProviders;
|
||||||
var providerConfig =
|
var providerConfig =
|
||||||
@@ -462,9 +420,6 @@ class _TwoFactorAuthenticationPageState
|
|||||||
_showResendAction.value = true;
|
_showResendAction.value = true;
|
||||||
_minVerificationPeriod =
|
_minVerificationPeriod =
|
||||||
providerConfig.minVerificationCodeSendPeriod ?? 30;
|
providerConfig.minVerificationCodeSendPeriod ?? 30;
|
||||||
if (type == TwoFaProviderType.SMS) {
|
|
||||||
_startListenForSmsCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
alt_sms_autofill:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: alt_sms_autofill
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.0.0"
|
|
||||||
archive:
|
archive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ dependencies:
|
|||||||
preload_page_view: ^0.1.6
|
preload_page_view: ^0.1.6
|
||||||
flutter_localizations:
|
flutter_localizations:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
alt_sms_autofill: ^1.0.0
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
Reference in New Issue
Block a user