Giter Club home page Giter Club logo

Comments (4)

hszeto avatar hszeto commented on June 4, 2024 1

are you running react-native-aws-cognito-js version 0.0.4 ?

from react-native-aws-cognito-js.

MattyK14 avatar MattyK14 commented on June 4, 2024

I was not. So I should be able to use this to not force the user to enter their credentials each time they open the app?

from react-native-aws-cognito-js.

vvavepacket avatar vvavepacket commented on June 4, 2024

@MattyK14 how were you able to read cognitoUser from MemoryStorage ?

I'm using your code snippet, but it returns null

export const checkIfLoggedIn = () => {
    return (dispatch) => {
        dispatch({ type: DO_NOTHING });
        var userPool = new CognitoUserPool(appConfig);
        var cognitoUser = userPool.getCurrentUser();
        console.log(cognitoUser);
        if (cognitoUser != null) {
            cognitoUser.getSession(function(err, session) {
                if (err) {
                    console.log(err);
                    return;
                }
                console.log('session validity: ' + session.isValid());

                // NOTE: getSession must be called to authenticate user before calling getUserAttributes
                cognitoUser.getUserAttributes(function(err, attributes) {
                    if (err) {
                        // Handle error
                    } else {
                        // Do something with attributes
                        console.log(attributes);
                    }
                });
                // in the future, you can insert here code to set token to access aws resources based on user access
                Actions.main({ type: 'reset' });
            });
        }
    }
};

from react-native-aws-cognito-js.

MattyK14 avatar MattyK14 commented on June 4, 2024

@vvavepacket I was, but it was super inconsistent and had to shelf it for now. Sometimes cognitoUser would come back null.

from react-native-aws-cognito-js.

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.