Created
July 2, 2011 06:18
-
-
Save hiromi2424/1059790 to your computer and use it in GitHub Desktop.
TwitterKit.TwitterOauthAuthenticate design
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AppController extends Controller { | |
public $components = array( | |
'Auth' => array( | |
'authenticate' => array( | |
'TwitterKit.TwitterOauth', | |
), | |
), | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('TwitterOauthAuthenticate', 'TwitterKit.Controller/Component/Auth'); | |
class UsersController extends AppController { | |
public $components = array( | |
'TwitterKit.Twitter', | |
); | |
public $helpers = array( | |
'Js', | |
); | |
public function login() { | |
if ($this->Auth->login()) { | |
$this->Auth->flash(__('Successfully logged in')); | |
$this->redirect($this->Auth->redirect()); | |
} elseif (TwitterOauthAuthenticate::$error !== false) { | |
$this->Auth->flash(__d('twitter_kit', 'Authorization Error: %s', TwitterOauthAuthenticate::$error)); | |
} | |
} | |
public function login_twitter() { | |
$this->redirect($this->Twitter->getAuthenticateUrl()); | |
} | |
public function logout() { | |
$this->Auth->flash(__('Successfully logged out')); | |
$this->redirect($this->Auth->logout()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment