Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example error #19

Closed
GoogleCodeExporter opened this issue Mar 21, 2015 · 3 comments
Closed

Example error #19

GoogleCodeExporter opened this issue Mar 21, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

Hi,

I had difficulties with your example.php, because the openId provider that I 
was using as test (Hyves.nl) uses POST callbacks rather than GET. So your login 
example failed because it only looks at $_GET['openid_mode']. I fixed this, and 
I also merged the Google example into the regular example (might be more 
convenient for most people). You might not agree with the latter, however here 
is the code.

Thanks!
Niels

>---



try {
    $openid_mode = '';
    if (isset($_GET['openid_mode']) ){
        $openid_mode=$_GET['openid_mode'];
    } else if (isset($_POST['openid_mode'])) {
        $openid_mode=$_POST['openid_mode'];
    } 
    if($openid_mode=='' ) {
        if (isset($_POST['openid_identifier'])) {
            $openid = new LightOpenID;

            // Google only provider
            if (strpos($_POST['openid_identifier'],'google')!==FALSE || 
                strpos($_POST['openid_identifier'],'gmail')!==FALSE) {
                $openid->identity = 'https://www.google.com/accounts/o8/id';
            } else {
                $openid->identity = $_POST['openid_identifier'];
            }
            header('Location: ' . $openid->authUrl());
        }
?>
<form action="" method="post">
    OpenID: <input type="text" name="openid_identifier" /> <button>Submit</button>
</form>
<?php
    } elseif ($openid_mode == 'cancel'   ) {
        echo 'User has canceled authentication!';
    } else {
        $openid = new LightOpenID;
        echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.';
    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}


Original issue reported on code.google.com by nielsba...@gmail.com on 22 Nov 2010 at 12:47

@GoogleCodeExporter
Copy link
Author

You've broken the support for google profiles while merging the examples (urls 
like http://google.com/profiles/login). Don't do things like guessing what a 
openid identifier might be -- it's wrong, and can easily cause problems. And 
even if it doesn't, it's confusing to the user, because it works differently on 
different websites. That's one of the reasons why google-example.php has a 
button.

That said, I'll push a commit soon, that fixes it.

Original comment by mewp...@gmail.com on 22 Nov 2010 at 11:43

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

I have added $openid->mode that returns openid.mode either from $_GET or 
$_POST, depending on where it's avaiable.

Original comment by mewp...@gmail.com on 22 Nov 2010 at 3:29

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

That's cool, thanx!

Original comment by nielsba...@gmail.com on 24 Nov 2010 at 11:02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant