views:

249

answers:

1

I have a table "users" and I want to enable my visitors to login with their openID Account. For this I use the OpenId Component for Cakephp and it works fine (When I login with the Google URL I receive the "successfully authenticated!" notification).

But now I'm kind of stuck because I don't know how to go on from there.

  • Do I have to create a User-Entry for every user which has a new entry in the "oid_associations" table (I save all OpenId interaction in the mysql database)?
  • Do I have to authenticate the User after the login (or is the OpenID-component doing that automatically?).
  • Am I completely misunderstanding the concept?
+2  A: 

No, you don't have to access the "oid_associations" table, it is a table which is only used by the OpenID library.

Instead, you can use the identity_url to figure out whether it is a new user. If that's the case, you can then create an entry in your "users" table. For example (assuming your "users" table has an "openid" column):

$response = $this->Openid->getResponse($returnTo);

if ($response->status == Auth_OpenID_SUCCESS) {
    $user = $this->User->findByOpenid($response->identity_url);
    if ($user) {
        // existing user
    } else {
        // new user -> create user entry in the database
    }
}

I'm not sure I understand your second question correctly. If someone logs in with an OpenID and you get an Auth_OpenID_SUCESS response, then this means this user was sucessfully authenticated. How you use this information in your application is up to you.

I hope this answers your questions.

dhofstet
thank you that really helped me and now I also understand how (respectively where) to authenticate the user.
nolandark