Code Monkey home page Code Monkey logo

Comments (4)

eap avatar eap commented on May 27, 2024 2

This still seems to be an issue. Has the change been rolled back?

from react-google-login.

RyanEwen avatar RyanEwen commented on May 27, 2024 1

@dskrenta I looked at the code and made a change similar to what you suggested. I decided to re-use the existing onSuccess instead, though, so that clicking login or being previously logged in have the same effect.

For those who want to try this out right away:
npm install https://github.com/RyanEwen/react-google-login.git#8199d9

from react-google-login.

RyanEwen avatar RyanEwen commented on May 27, 2024

I have the same issue. Wasn't sure if it's an option I am not understanding or a bug. I don't want to force users to re-login on each visit.

from react-google-login.

dskrenta avatar dskrenta commented on May 27, 2024

I also had the same issue with this implementation. No current releases have the option however it is pretty simple to add if you are familiar with the google sign in api. Eventually someone could probably do a PR with the option for persistence. Here is a snippet from the source with some simple modifications to allow for user persistence:

window.gapi.load('auth2', () => {
  this.setState({
    disabled: false,
  });
  if (!window.gapi.auth2.getAuthInstance()) {
    window.gapi.auth2.init(params).then(
      () => {
        if (window.gapi.auth2.getAuthInstance().currentUser.get()) {
          this.props.alreadyAuthenticated('Already Authenticated!');
        }
      },
      err => onFailure(err)
    );
  }
  if (autoLoad) {
    this.signIn();
  }
});

Where alreadyAuthenticated is a callback passed through the props. You can fetch the same data that onSuccess returns also if you move some of the code into a shared formatting helper function. This sign in will persist until window.gapi.auth2.getAuthInstance().signOut() is called or if chrome logs the user out at some point.

from react-google-login.

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.