Skip to content

Instantly share code, notes, and snippets.

@hiromi2424
Created July 2, 2011 06:18
Show Gist options
  • Save hiromi2424/1059790 to your computer and use it in GitHub Desktop.
Save hiromi2424/1059790 to your computer and use it in GitHub Desktop.
TwitterKit.TwitterOauthAuthenticate design
<?php
class AppController extends Controller {
public $components = array(
'Auth' => array(
'authenticate' => array(
'TwitterKit.TwitterOauth',
),
),
);
}
<?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