123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- require_once INSTALLDIR.'/plugins/OpenID/openid.php';
- class OpenidtrustAction extends Action
- {
- var $trust_root;
- var $allowUrl;
- var $denyUrl;
- var $user;
-
- function isReadOnly($args)
- {
- return false;
- }
-
- function title()
- {
-
- return _m('OpenID Identity Verification');
- }
- function prepare(array $args = array())
- {
- parent::prepare($args);
- common_ensure_session();
- $this->user = common_current_user();
- if(empty($this->user)){
-
- common_set_returnto($_SERVER['REQUEST_URI']);
- common_redirect(common_local_url('login'));
- }
- $this->trust_root = $_SESSION['openid_trust_root'];
- $this->allowUrl = $_SESSION['openid_allow_url'];
- $this->denyUrl = $_SESSION['openid_deny_url'];
- if(empty($this->trust_root) || empty($this->allowUrl) || empty($this->denyUrl)){
-
- $this->clientError(_m('This page should only be reached during OpenID processing, not directly.'));
- }
- return true;
- }
- function handle()
- {
- parent::handle();
- if($_SERVER['REQUEST_METHOD'] == 'POST'){
- $this->handleSubmit();
- }else{
- $this->showPage();
- }
- }
- function handleSubmit()
- {
- global $_PEAR;
- unset($_SESSION['openid_trust_root']);
- unset($_SESSION['openid_allow_url']);
- unset($_SESSION['openid_deny_url']);
- if($this->arg('allow'))
- {
-
- $user_openid_trustroot = new User_openid_trustroot();
- $user_openid_trustroot->user_id = $this->user->id;
- $user_openid_trustroot->trustroot = $this->trust_root;
- $user_openid_trustroot->created = common_sql_now();
- if (!$user_openid_trustroot->insert()) {
- $err = &$_PEAR->getStaticProperty('DB_DataObject','lastError');
- }
- common_redirect($this->allowUrl, $code=302);
- }else{
- common_redirect($this->denyUrl, $code=302);
- }
- }
-
- function showPageNotice()
- {
-
- $this->element('p',null,sprintf(_m('%s has asked to verify your identity. Click Continue to verify your identity and login without creating a new password.'),$this->trust_root));
- }
-
- function showContent()
- {
- $this->elementStart('form', array('method' => 'post',
- 'id' => 'form_openidtrust',
- 'class' => 'form_settings',
- 'action' => common_local_url('openidtrust')));
- $this->elementStart('fieldset');
-
- $this->submit('allow', _m('BUTTON','Continue'));
-
- $this->submit('deny', _m('BUTTON','Cancel'));
- $this->elementEnd('fieldset');
- $this->elementEnd('form');
- }
- }
|