Code Monkey home page Code Monkey logo

Comments (16)

furaiev avatar furaiev commented on September 21, 2024

Yes, it returns a challengeName, search challenge in this repo.

from amazon-cognito-identity-dart-2.

newdev8 avatar newdev8 commented on September 21, 2024

I mean check it once the user is already logged in.
In my case, I am making a settings screen, where there is an option to activate 2MFA, so that's why I need to check it.

from amazon-cognito-identity-dart-2.

furaiev avatar furaiev commented on September 21, 2024

So, in the login process, you already know if the user enters the MFA codes or not.
Based on this data you can determine if 2MFA is activated, correct?

from amazon-cognito-identity-dart-2.

newdev8 avatar newdev8 commented on September 21, 2024

Normally yes, but what if the user is logged in in multiple devices, and in one of them disables/enables 2MFA? That would not update on all devices.

from amazon-cognito-identity-dart-2.

furaiev avatar furaiev commented on September 21, 2024

I think you should keep this value in your DB then.

from amazon-cognito-identity-dart-2.

newdev8 avatar newdev8 commented on September 21, 2024

That's a bad practice.

from amazon-cognito-identity-dart-2.

furaiev avatar furaiev commented on September 21, 2024

@lain-ke
please add this code into your flutter/.pub-cache-hosted/pub.dartlang.org/amazon-cognito-identity-dart-2-0.1.9/lib/src/cognito_user.dart and build the app.
Try to call this method. If it works I'll publish a new version.
In my case I don't have the key MFAOptions in the response, but I suppose this is adjustable in the AWS admin panel.

/// This is used by an authenticated user to get the MFAOptions
  Future<List> getMFAOptions(callback) async {
    if (!(_signInUserSession != null && _signInUserSession.isValid())) {
      throw Exception('User is not authenticated');
    }

    final paramsReq = {
      'AccessToken': _signInUserSession.getAccessToken().getJwtToken(),
    };
    final userData = await client.request('GetUser', paramsReq);
    print(userData);
    return userData['MFAOptions'];
  }

from amazon-cognito-identity-dart-2.

newdev8 avatar newdev8 commented on September 21, 2024

Hello, I also don't have the MFAOptions key parameter, is there any way to enable it?

from amazon-cognito-identity-dart-2.

furaiev avatar furaiev commented on September 21, 2024

Yeap, in this case, it works:

await cognitoManager.cognitoUser.enableMfa();
var mfaOptions = await cognitoManager.cognitoUser.getMFAOptions();
print(mfaOptions);

from amazon-cognito-identity-dart-2.

furaiev avatar furaiev commented on September 21, 2024

@lain-ke do you have any feedback? Is this code is useful?

from amazon-cognito-identity-dart-2.

ShogoTsuchiya avatar ShogoTsuchiya commented on September 21, 2024

I'll appreciate it if you'd tell me how to use '.getMFAOptions()' method.
The sample code furaiev showed above contains 'cognitoManager', but it doesn't work.
(Actually, my AndroidStudio says 'IT'S UNDEFINED NAME!' , so I can't complete compiling.)

I've looked up about cognitoManager in the documentation for hundred times, but I couldn't find about that.
How do I compose cognitoManager, or, how do I use '.getMFAOptions()'?

from amazon-cognito-identity-dart-2.

furaiev avatar furaiev commented on September 21, 2024

@ShogoTsuchiya cognitoManager is a custom class that keeps CognitoUserPool and CognitoUser.
You can create and use directly CognitoUser.

from amazon-cognito-identity-dart-2.

ShogoTsuchiya avatar ShogoTsuchiya commented on September 21, 2024

Thank you for your reply. I tried direct use like this.

await cognitoUser.getMFAOptions();

but it always returns NULL...

from amazon-cognito-identity-dart-2.

furaiev avatar furaiev commented on September 21, 2024

it means that server returns userData without MFAOptions

return userData['MFAOptions'];

from amazon-cognito-identity-dart-2.

ShogoTsuchiya avatar ShogoTsuchiya commented on September 21, 2024

Thanks!
You mean I can get MFAOptions info as a part of attributes, like 'sub' and 'email_verified' ?

from amazon-cognito-identity-dart-2.

alondahari avatar alondahari commented on September 21, 2024

Looks like the MFA options are in userData['UserMFASettingList'], so the current implementation of cognitoUser.getMFAOptions() will always return null.

from amazon-cognito-identity-dart-2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.