Search code examples
openid

Openid testing if a user is already signed in using lightopenid


I'm trying to create a low friction sign in implementation for my users using lightopenid and I've run into a use case that's causing problems.

  1. User signs out of google
  2. User navigates to my web site and is challenged for their credentials

The challenge happens because of the following code I use to authenticate the user but in the case where the user is not logged in the whole google challenge flow is activated

$openid->identity = 'https://www.google.com/accounts/o8/id';
header('Location: ' . $openid->authUrl());

In summary if the user is already signed in everything works smoothly. I'd like to be able to test if the user is signed in without an authentication challenge which is a pretty bad experience for a first time user. I can then implement a button allowing the user to sign in but still allow them to view the majority of the content on the website.


Solution

  • You can use

    $openid->authUrl(true)
    

    to authenticate without going through the sign in process