13

I have went through the local_auth package and it works fine, but it does not have an option to authenticate with password or pin. Help appreciated!

String _authorized = 'Not Authorized';//Start

Future<Null> _authenticate() async {
    final LocalAuthentication auth = new LocalAuthentication();
    bool authenticated = false;
    try {
        authenticated = await auth.authenticateWithBiometrics(
        localizedReason: 'Scan your fingerprint to authenticate',
        useErrorDialogs: true,
        stickyAuth: false);
        authenticated = await auth.authenticateWithBiometrics(localizedReason: 'Authenticate');
    } on PlatformException catch (e) {
        print(e);
    }
    if (!mounted) return;

    setState(() {
      _authorized = authenticated ? 'Authorized' : 'Not Authorized';
    });
}//End

So this is the example code and you can use biometric authentication but what about the default Pin/Password authentication that is also present with fingerprint.

Keshava Muraari
  • 216
  • 2
  • 9
  • Please put some code. – ibhavikmakwana Aug 27 '18 at 10:39
  • 1
    I've found [this answer](https://stackoverflow.com/a/45718948/3123267) for native Android to force the user to reauthenticate. but it seems nobody wrote any plugin for this method...If this is what you seek, I suggest adding a feature request on flutter's GitHub repository. – Yamin Aug 27 '18 at 14:53

1 Answers1

7

For security reason, mobile (iOS/Android) will only authenticate user by biometrics, not system password/pin. If you want to let user authenticate by other methods than biometrics, the app itself must store and process (encrypted) credential which is totally separated from system password/pin.

You can see this behavior (to use system-biometrics AND app-specific credential) in many bank/financial related app, such as https://play.google.com/store/apps/details?id=com.konylabs.capitalone&hl=en

TruongSinh
  • 4,662
  • 32
  • 52