question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic sign-in

See original GitHub issue

The base example in the README displays a log in button when you launch the app.

This is not how most apps work, and it probably should be updated to something more common.

Most apps will silently and automatically reestablish your previous session, if you close the tab and reopen the app.

I have not been able to achieve that react-oidc-context - I only seem to get myself into infinite circular logins.

I’m coming from oidc-react, which would automatically take care of this. (but which I have other problems with - namely, silent renewals do not seem to work correctly, which you seem to have given more consideration to.)

With this library, it looks like I have to manually call a function like signinSilent or signinRedirect to make it work?

EDIT: it turns out signinRedirect might either redirect or just silently resume a prior session, if possible - just the function name is a little misleading here.

I’m really missing a better example here, please.

I’m sure others have gotten this to work? It seems the package is very popular, and I doubt everyone is using the example from the README, making their users manually sign in every time they visit the page? 🙂

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sJJdGGcommented, Aug 30, 2022

Here’s the custom hook I use which covers corner cases I’ve tried

import { hasAuthParams, useAuth } from 'react-oidc-context';

const useAutoLogin = () => {
  const auth = useAuth();

  useEffect(() => {
    if (
      !hasAuthParams() &&
      !auth.isAuthenticated &&
      !auth.activeNavigator &&
      !auth.isLoading
    ) {
      auth.signinRedirect();
    }
  }, [auth]);
};

@pamapa Would be happy to let me know if there’s any problem with this implementation.

1reaction
mindplay-dkcommented, Aug 30, 2022

Oh, it’s a top level export. 😊

Yes, with your suggested change, logout and redirection now works as well!

Thanks!

It’s an open source project - I will post a link to the full working example for future reference.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic sign-in and sign-out | Authentication
Automatic sign-in is intended to complement our Sign in with Google button and One Tap dialogs. It is designed to be used across...
Read more >
Stay signed in or out of your Google Account
You'll be automatically signed out. Stay signed out of non-Google accounts. These tips can help you stop non-Google accounts from automatically signing you...
Read more >
Auto Login
Automatically login to your favourite websites without entering credentials , even for Basic Auth Now.
Read more >
3 Ways to Automatically Sign In to a User Account on ...
1. Use Netplwiz to Sign In to a User Account Automatically · Press Windows Key + R, type netplwiz in the box, and...
Read more >
Automatically log in to your Windows 10 PC - CNET
Automatically log in to your Windows 10 PC · 1. Open the Run command box (Start > All apps > Windows System >...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found