public function __construct($provider_name, $settings) { parent::__construct($provider_name, $settings); $this->openid = new Vendor_LightOpenID(); // Is this a generic OpenID, or a specific ("branded" / shows button on login page) one? $this->generic = $provider_name == 'openid'; }
/** * Return - Called when we return from the provider's login page. Validate the login. Check if * the user already has an account, and redirect to a registration page if not. */ public function action_return() { $provider_name = $provider = $this->request->param('id'); $provider = Membership_Provider::factory($provider); if (!($user = $provider->verifyLogin())) { echo 'Failed'; die; } // Try to look up this user $identity = ORM::factory('identity')->where('identity', '=', $user['identity'])->find(); // If they're loaded, they're a member if ($identity->loaded()) { // Log in as this user $identity->login(); $this->session->set('message', 'Welcome back, ' . html::chars($identity->member->name) . '!'); $this->request->redirect(''); } // Otherwise, if we're here, this identity isn't associated with any one yet. // Are they currently logged in? if ($this->membership->logged_in()) { $member = $this->membership->get_member(); // Associate their new OpenID with their current account. // TODO: Remove code duplication with action_register() below. $identity = ORM::factory('identity'); $identity->identity = $user['identity']; $identity->member = $member; $identity->provider = $provider_name; $identity->display_name = $user['display_name']; $identity->save(); $this->session->set('message', 'Attached identity "' . html::chars($user['display_name']) . '" (' . $provider_name . ') to your account.'); $this->request->redirect('member'); } // Otherwise, they need a new account // Redirect to the registration page $this->session->set('reg_openid', $user); $this->session->set('reg_openid_provider', $provider_name); $this->request->redirect('member/register'); }
public function __construct($provider_name, $options) { parent::__construct($provider_name, $options); $this->oauth = new OAuth($options['key'], $options['secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); }