Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>How to log in the user?</h1> <p>In your example, there is a line showing how to complete the authentication:</p> <pre><code>echo 'User ' . ($openid-&gt;validate() ? $openid-&gt;identity . ' has ' : 'has not ') . 'logged in.'; </code></pre> <p>If <code>$openid-&gt;validate()</code> returns true, it means that the user that claims to be <code>$openid-&gt;identity</code> is authenticated.</p> <p>If you'd compare it to standard authentication:</p> <h2>Standard auth:</h2> <ul> <li>The User inputs login and password</li> <li>The Server checks whether there is such a pair of login and password.</li> <li>If there is, the user is authenticated (with the login he provided), so we set a cookie to remember him(or whatever else you want to do on a successful login).</li> </ul> <h2>OpenID auth(with LightOpenID):</h2> <ul> <li>The User inputs an openid identity</li> <li>The Server uses LightOpenID to authenticate it, then calls <code>$openid-&gt;validate()</code></li> <li>If <code>validate()</code> returns true, the user is authenticated (with <code>$openid-&gt;identity</code>), so we set a cookie to remember him(or whatever else you want to do on a successful login).</li> </ul> <p>Basically, once you confirm that the user is the one who he claims he is (i.e. he has authenticated), you proceed as if it was a normal auth.</p> <p>Usually, you have to store the identity somewhere, along with a session id.</p> <h1>From where I must get logged user info (as username, mail) ?</h1> <p>The username is in <code>$openid-&gt;identity</code>. However, you might want to use a nickname as a displayed name. Getting a nickname and an email address however, requires additional configuration. Basically, before calling <code>$openid-&gt;authUrl()</code>, you'd have to add:</p> <pre><code>$openid-&gt;required = array('namePerson/friendly', 'contact/email'); </code></pre> <p>That line would cause LightOpenID to requests these parameters. You can see a list of other parameters (which may or may not be supported by OPs) at <a href="http://www.axschema.org/types/" rel="noreferrer">axschema.org</a>. Then, to get the values of those, after calling <code>validate()</code>, call <code>$openid-&gt;getAttributes()</code>. It will return all avaiable paramerers, for example:</p> <pre><code>array( [namePerson/friendly] =&gt; Mewp [contact/email] =&gt; mewp@example.com ) </code></pre> <p>However, be aware of the fact, that this list can contain other parameters and may not contain the ones you requested. Basically, the OP is free to return whatever it wants to, so you need to be prepared for the lack of some values.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload