Example #1
0
 public function handle($identity, $password)
 {
     $openid = $this->getOpenidProvider($identity);
     if ($openid !== false) {
         $identity = $openid->getIdentifier();
         if (!empty($identity)) {
             // here we can add addition extensions depending what
             // informations we need from the user
             $sreg = new Extension\Sreg(array('fullname', 'nickname', 'gender', 'timezone'));
             if ($openid->hasExtension($sreg->getNs())) {
                 $openid->add($sreg);
             } else {
                 $ax = new Extension\Ax(array('fullname' => 'http://axschema.org/namePerson', 'firstname' => 'http://axschema.org/namePerson/first', 'lastname' => 'http://axschema.org/namePerson/last', 'gender' => 'http://axschema.org/person/gender', 'timezone' => 'http://axschema.org/pref/timezone'));
                 if ($openid->hasExtension($ax->getNs())) {
                     $openid->add($ax);
                 }
             }
             // redirect
             $openid->redirect();
         } else {
             throw new Exception('Invalid identity');
         }
     } else {
         throw new Exception('Invalid openid identity');
     }
 }