Flutter Pin/Password/Pattern Integration
Asked Answered
E

1

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.

Eschar answered 27/8, 2018 at 10:17 Comment(2)
Please put some code.Phrensy
I've found this answer 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.Yak
F
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

Farmyard answered 27/2, 2019 at 12:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.