diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 86893fd1b..bee0fa2b6 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -7,6 +7,7 @@
FlutterApplication and put your custom class here. -->
+
"Authenticated";
String get authentication => "Authentication";
String get available_balance => "Available Balance";
+ String get biometric_auth_reason => "Scan your fingerprint to authenticate";
String get cancel => "Cancel";
String get change => "Change";
String get change_currency => "Change Currency";
@@ -316,6 +317,8 @@ class $de extends S {
@override
String get hidden_balance => "Verstecktes Gleichgewicht";
@override
+ String get biometric_auth_reason => "Scannen Sie Ihren Fingerabdruck zur Authentifizierung";
+ @override
String get transaction_sent => "Transaktion gesendet!";
@override
String get password => "Passwort";
@@ -864,6 +867,8 @@ class $hi extends S {
@override
String get hidden_balance => "छिपा हुआ संतुलन";
@override
+ String get biometric_auth_reason => "प्रमाणित करने के लिए अपने फ़िंगरप्रिंट को स्कैन करें";
+ @override
String get transaction_sent => "भेजा गया लेन-देन";
@override
String get password => "पारण शब्द";
@@ -1412,6 +1417,8 @@ class $ru extends S {
@override
String get hidden_balance => "Скрытый баланс";
@override
+ String get biometric_auth_reason => "Отсканируйте свой отпечаток пальца для аутентификации";
+ @override
String get transaction_sent => "Tранзакция отправлена!";
@override
String get password => "Password";
@@ -1960,6 +1967,8 @@ class $ko extends S {
@override
String get hidden_balance => "숨겨진 균형";
@override
+ String get biometric_auth_reason => "지문을 스캔하여 인증";
+ @override
String get transaction_sent => "거래가 전송되었습니다!";
@override
String get password => "암호";
@@ -2508,6 +2517,8 @@ class $pt extends S {
@override
String get hidden_balance => "Saldo escondido";
@override
+ String get biometric_auth_reason => "Digitalize sua impressão digital para autenticar";
+ @override
String get transaction_sent => "Transação enviada!";
@override
String get password => "Senha";
@@ -3056,6 +3067,8 @@ class $ja extends S {
@override
String get hidden_balance => "隠れたバランス";
@override
+ String get biometric_auth_reason => "प指紋をスキャンして認証する";
+ @override
String get transaction_sent => "トランザクションが送信されました!";
@override
String get password => "パスワード";
@@ -3608,6 +3621,8 @@ class $pl extends S {
@override
String get hidden_balance => "Ukryta równowaga";
@override
+ String get biometric_auth_reason => "Zeskanuj swój odcisk palca, aby go uwierzytelnić";
+ @override
String get transaction_sent => "Transakcja wysłana!";
@override
String get password => "Hasło";
@@ -4156,6 +4171,8 @@ class $es extends S {
@override
String get hidden_balance => "Balance oculto";
@override
+ String get biometric_auth_reason => "Escanee su huella digital para autenticar";
+ @override
String get transaction_sent => "Transacción enviada!";
@override
String get password => "Contraseña";
@@ -4704,6 +4721,8 @@ class $nl extends S {
@override
String get hidden_balance => "Verborgen balans";
@override
+ String get biometric_auth_reason => "Scan uw vingerafdruk om te verifiëren";
+ @override
String get transaction_sent => "Transactie verzonden!";
@override
String get password => "Wachtwoord";
@@ -5252,6 +5271,8 @@ class $zh extends S {
@override
String get hidden_balance => "隐藏余额";
@override
+ String get biometric_auth_reason => "掃描指紋以進行身份驗證";
+ @override
String get transaction_sent => "交易已发送";
@override
String get password => "密码";
diff --git a/lib/src/domain/common/biometric_auth.dart b/lib/src/domain/common/biometric_auth.dart
new file mode 100644
index 000000000..50fff4cf8
--- /dev/null
+++ b/lib/src/domain/common/biometric_auth.dart
@@ -0,0 +1,24 @@
+import 'package:local_auth/local_auth.dart';
+import 'package:flutter/services.dart';
+import 'package:cake_wallet/generated/i18n.dart';
+
+class BiometricAuth {
+
+ Future isAuthenticated() async {
+ final LocalAuthentication _localAuth = LocalAuthentication();
+
+ try {
+ return await _localAuth.authenticateWithBiometrics(
+ localizedReason: S.current.biometric_auth_reason,
+ useErrorDialogs: true,
+ stickyAuth: false
+ );
+ } on PlatformException
+ catch(e) {
+ print(e);
+ }
+
+ return false;
+ }
+
+}
\ No newline at end of file
diff --git a/lib/src/screens/auth/auth_page.dart b/lib/src/screens/auth/auth_page.dart
index 5711b8b5e..e963577c8 100644
--- a/lib/src/screens/auth/auth_page.dart
+++ b/lib/src/screens/auth/auth_page.dart
@@ -6,6 +6,8 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/stores/auth/auth_state.dart';
import 'package:cake_wallet/src/stores/auth/auth_store.dart';
import 'package:cake_wallet/src/screens/pin_code/pin_code.dart';
+import 'package:cake_wallet/src/stores/settings/settings_store.dart';
+import 'package:cake_wallet/src/domain/common/biometric_auth.dart';
typedef OnAuthenticationFinished = void Function(bool, AuthPageState);
@@ -33,6 +35,26 @@ class AuthPageState extends State {
@override
Widget build(BuildContext context) {
final authStore = Provider.of(context);
+ final settingsStore = Provider.of(context);
+
+ if (settingsStore.allowBiometricalAuthentication) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ final biometricAuth = BiometricAuth();
+ biometricAuth.isAuthenticated().then(
+ (isAuth) {
+ if (isAuth) {
+ authStore.biometricAuth();
+ _key.currentState.showSnackBar(
+ SnackBar(
+ content: Text(S.of(context).authenticated),
+ backgroundColor: Colors.green,
+ ),
+ );
+ }
+ }
+ );
+ });
+ }
reaction((_) => authStore.state, (AuthState state) {
if (state is AuthenticatedSuccessfully) {
diff --git a/lib/src/stores/auth/auth_store.dart b/lib/src/stores/auth/auth_store.dart
index 966ccc0b1..91912d7da 100644
--- a/lib/src/stores/auth/auth_store.dart
+++ b/lib/src/stores/auth/auth_store.dart
@@ -91,4 +91,9 @@ abstract class AuthStoreBase with Store {
return Duration(milliseconds: timeout);
}
+
+ @action
+ void biometricAuth() {
+ state = AuthenticatedSuccessfully();
+ }
}
diff --git a/pubspec.lock b/pubspec.lock
index d4adb3dbb..ab6b8a29d 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -406,6 +406,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.19"
+ local_auth:
+ dependency: "direct main"
+ description:
+ name: local_auth
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "0.6.1"
logging:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index e20521171..9df3dd52b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -45,6 +45,7 @@ dependencies:
path: ./cw_monero
hive: ^1.2.0
hive_flutter: ^0.2.1
+ local_auth: ^0.6.1
package_info: ^0.4.0+13
# The following adds the Cupertino Icons font to your application.
diff --git a/res/values/strings_de.arb b/res/values/strings_de.arb
index 8dd44f7b6..ba935a2b5 100644
--- a/res/values/strings_de.arb
+++ b/res/values/strings_de.arb
@@ -338,5 +338,7 @@
"add_new_word" : "Neues Wort hinzufügen",
"incorrect_seed" : "Der eingegebene Text ist ungültig.",
+ "biometric_auth_reason" : "Scannen Sie Ihren Fingerabdruck zur Authentifizierung",
+
"version" : "Ausführung ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb
index 3e878bbc3..a3cd02767 100644
--- a/res/values/strings_en.arb
+++ b/res/values/strings_en.arb
@@ -338,5 +338,7 @@
"add_new_word" : "Add new word",
"incorrect_seed" : "The text entered is not valid.",
+ "biometric_auth_reason" : "Scan your fingerprint to authenticate",
+
"version" : "Version ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb
index 3d8e9472d..a4123dcf2 100644
--- a/res/values/strings_es.arb
+++ b/res/values/strings_es.arb
@@ -338,5 +338,7 @@
"add_new_word" : "Agregar palabra nueva",
"incorrect_seed" : "El texto ingresado no es válido.",
+ "biometric_auth_reason" : "Escanee su huella digital para autenticar",
+
"version" : "Versión ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_hi.arb b/res/values/strings_hi.arb
index 712bc9082..a80b20ce2 100644
--- a/res/values/strings_hi.arb
+++ b/res/values/strings_hi.arb
@@ -338,5 +338,7 @@
"add_new_word" : "नया शब्द जोड़ें",
"incorrect_seed" : "दर्ज किया गया पाठ मान्य नहीं है।",
+ "biometric_auth_reason" : "प्रमाणित करने के लिए अपने फ़िंगरप्रिंट को स्कैन करें",
+
"version" : "संस्करण ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_ja.arb b/res/values/strings_ja.arb
index 0dd826a09..fde4c668d 100644
--- a/res/values/strings_ja.arb
+++ b/res/values/strings_ja.arb
@@ -338,5 +338,7 @@
"add_new_word" : "新しい単語を追加",
"incorrect_seed" : "入力されたテキストは無効です。",
+ "biometric_auth_reason" : "प指紋をスキャンして認証する",
+
"version" : "バージョン ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_ko.arb b/res/values/strings_ko.arb
index 1be04579d..ed8a1e7f1 100644
--- a/res/values/strings_ko.arb
+++ b/res/values/strings_ko.arb
@@ -338,5 +338,7 @@
"add_new_word" : "새로운 단어 추가",
"incorrect_seed" : "입력하신 텍스트가 유효하지 않습니다.",
+ "biometric_auth_reason" : "지문을 스캔하여 인증",
+
"version" : "버전 ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_nl.arb b/res/values/strings_nl.arb
index 7690fd275..c394608e4 100644
--- a/res/values/strings_nl.arb
+++ b/res/values/strings_nl.arb
@@ -338,5 +338,7 @@
"add_new_word" : "Nieuw woord toevoegen",
"incorrect_seed" : "De ingevoerde tekst is niet geldig.",
+ "biometric_auth_reason" : "Scan uw vingerafdruk om te verifiëren",
+
"version" : "Versie ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_pl.arb b/res/values/strings_pl.arb
index fdbd6df3f..f59dd2c9f 100644
--- a/res/values/strings_pl.arb
+++ b/res/values/strings_pl.arb
@@ -338,5 +338,7 @@
"add_new_word" : "Dodaj nowe słowo",
"incorrect_seed" : "Wprowadzony tekst jest nieprawidłowy.",
+ "biometric_auth_reason" : "Zeskanuj swój odcisk palca, aby go uwierzytelnić",
+
"version" : "Wersja ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_pt.arb b/res/values/strings_pt.arb
index 366ec1e81..b0e75314b 100644
--- a/res/values/strings_pt.arb
+++ b/res/values/strings_pt.arb
@@ -338,5 +338,7 @@
"add_new_word" : "Adicionar nova palavra",
"incorrect_seed" : "O texto digitado não é válido.",
+ "biometric_auth_reason" : "Digitalize sua impressão digital para autenticar",
+
"version" : "Versão ${currentVersion}"
}
diff --git a/res/values/strings_ru.arb b/res/values/strings_ru.arb
index 3e5ededb0..7a6cfdae1 100644
--- a/res/values/strings_ru.arb
+++ b/res/values/strings_ru.arb
@@ -338,5 +338,7 @@
"add_new_word" : "Добавить новое слово",
"incorrect_seed" : "Введенный текст некорректный.",
+ "biometric_auth_reason" : "Отсканируйте свой отпечаток пальца для аутентификации",
+
"version" : "Версия ${currentVersion}"
}
\ No newline at end of file
diff --git a/res/values/strings_zh.arb b/res/values/strings_zh.arb
index 451168f6b..7607dd131 100644
--- a/res/values/strings_zh.arb
+++ b/res/values/strings_zh.arb
@@ -338,5 +338,7 @@
"add_new_word" : "添加新词",
"incorrect_seed" : "输入的文字无效。",
+ "biometric_auth_reason" : "掃描指紋以進行身份驗證",
+
"version" : "版 ${currentVersion}"
}
\ No newline at end of file