Note that there are some explanatory texts on larger screens.

plurals
  1. POUsers logged into other people's accounts
    primarykey
    data
    text
    <p>I have a script that gets Facebook user information (see below).</p> <p>The issue I've encountered during tests is that a user can end up getting logged in on someone else's account. This is obviously undesirable.</p> <p>This happens in the bit that says <code>if( $testuser != null )</code> where some code hooks into the login system of a web site bypassing the username+password phase and logs in a person according to their email address.</p> <p>My guess is that something similar is happening to a payment system I fixed a few months ago. In short, if two people were visiting the same page they could both end up benefiting from a transaction. This was solved by adding an id to the callback from the payment service. In the present case I'm not sure how I could implement that but I'd say an extra condition needs to be added before a user is logged in.</p> <p>What do you think is happening and what would be an appropriate/secure fix? </p> <pre><code>$token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $app_id . "&amp;redirect_uri=" . urlencode($my_url) . "&amp;client_secret=" . $app_secret . "&amp;code=" . $code; $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $graph_url = "https://graph.facebook.com/me?access_token=" . $params['access_token']; $testuser = json_decode(file_get_contents($graph_url)); if( $testuser != null ){ // Login code goes here $id = get_userid_by_email( $testuser-&gt;email ); // Use email as key as unique $user = new User($db); $user-&gt;signin_by_id( (int) $id ); $user-&gt;connect(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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