コード例 #1
0
ファイル: Adapter.php プロジェクト: romainneutron/Phraseanet
 protected function checkUserCredentials($client_id, $username, $password)
 {
     try {
         $this->setClient(API_OAuth2_Application::load_from_client_id($this->app, $client_id));
         $usr_id = $this->app['auth.native']->getUsrId($username, $password, Request::createFromGlobals());
         if (!$usr_id) {
             return false;
         }
         if (null === ($user = $this->app['manipulator.user']->getRepository()->find($usr_id))) {
             return false;
         }
         $account = $this->updateAccount($user);
         return ['redirect_uri' => $this->client->get_redirect_uri(), 'client_id' => $this->client->get_client_id(), 'account_id' => $account->get_id()];
     } catch (AccountLockedException $e) {
         return false;
     } catch (RequireCaptchaException $e) {
         return false;
     } catch (\Exception $e) {
         return false;
     }
 }
コード例 #2
0
 /**
  * @cover \Alchemy\Phrasea\Controller\Root\Developers::renewAppCallback
  */
 public function testRenewAppCallback()
 {
     $oauthApp = self::$DI['oauth2-app-user'];
     $this->XMLHTTPRequest('POST', '/developers/application/' . $oauthApp->get_id() . '/callback/', ['callback' => 'my.callback.com']);
     $this->assertTrue(self::$DI['client']->getResponse()->isOk());
     $content = json_decode(self::$DI['client']->getResponse()->getContent());
     $this->assertTrue($content->success);
     $oauthApp = new \API_OAuth2_Application(self::$DI['app'], $oauthApp->get_id());
     $this->assertEquals('my.callback.com', $oauthApp->get_redirect_uri());
 }