method
darcs-hash:20080702131507-84dde-507a6380fcab66c1fbcbaad6d1399c8a2f210acf.gz
This commit is contained in:
parent
8c1ac74f7c
commit
721d6f94c7
@ -58,14 +58,14 @@ class FinishopenidloginAction extends Action {
|
|||||||
_t(' so we must connect your OpenID to a local account. ' .
|
_t(' so we must connect your OpenID to a local account. ' .
|
||||||
' You can either create a new account, or connect with ' .
|
' You can either create a new account, or connect with ' .
|
||||||
' your existing account, if you have one.'));
|
' your existing account, if you have one.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_form($error=NULL, $username=NULL) {
|
function show_form($error=NULL, $username=NULL) {
|
||||||
common_show_header(_t('OpenID Account Setup'), NULL, $error,
|
common_show_header(_t('OpenID Account Setup'), NULL, $error,
|
||||||
array($this, 'show_top'));
|
array($this, 'show_top'));
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'account_connect',
|
'id' => 'account_connect',
|
||||||
'action' => common_local_url('finishopenidlogin')));
|
'action' => common_local_url('finishopenidlogin')));
|
||||||
common_element('h2', NULL,
|
common_element('h2', NULL,
|
||||||
@ -99,7 +99,7 @@ class FinishopenidloginAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function try_login() {
|
function try_login() {
|
||||||
|
|
||||||
$consumer = oid_consumer();
|
$consumer = oid_consumer();
|
||||||
|
|
||||||
$response = $consumer->complete(common_local_url('finishopenidlogin'));
|
$response = $consumer->complete(common_local_url('finishopenidlogin'));
|
||||||
@ -125,7 +125,7 @@ class FinishopenidloginAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = oid_get_user($canonical);
|
$user = oid_get_user($canonical);
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
oid_set_last($display);
|
oid_set_last($display);
|
||||||
oid_update_user($user, $sreg);
|
oid_update_user($user, $sreg);
|
||||||
@ -144,12 +144,12 @@ class FinishopenidloginAction extends Action {
|
|||||||
common_element('p', NULL, $msg);
|
common_element('p', NULL, $msg);
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_values($display, $canonical, $sreg) {
|
function save_values($display, $canonical, $sreg) {
|
||||||
common_ensure_session();
|
common_ensure_session();
|
||||||
$_SESSION['openid_display'] = $display;
|
$_SESSION['openid_display'] = $display;
|
||||||
$_SESSION['openid_canonical'] = $canonical;
|
$_SESSION['openid_canonical'] = $canonical;
|
||||||
$_SESSION['openid_sreg'] = $sreg;
|
$_SESSION['openid_sreg'] = $sreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_saved_values() {
|
function get_saved_values() {
|
||||||
@ -157,11 +157,11 @@ class FinishopenidloginAction extends Action {
|
|||||||
$_SESSION['openid_canonical'],
|
$_SESSION['openid_canonical'],
|
||||||
$_SESSION['openid_sreg']);
|
$_SESSION['openid_sreg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_new_user() {
|
function create_new_user() {
|
||||||
|
|
||||||
$nickname = $this->trimmed('newname');
|
$nickname = $this->trimmed('newname');
|
||||||
|
|
||||||
if (!Validate::string($nickname, array('min_length' => 1,
|
if (!Validate::string($nickname, array('min_length' => 1,
|
||||||
'max_length' => 64,
|
'max_length' => 64,
|
||||||
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
||||||
@ -173,36 +173,36 @@ class FinishopenidloginAction extends Action {
|
|||||||
$this->show_form(_t('Nickname not allowed.'));
|
$this->show_form(_t('Nickname not allowed.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (User::staticGet('nickname', $nickname)) {
|
if (User::staticGet('nickname', $nickname)) {
|
||||||
$this->show_form(_t('Nickname already in use. Try another one.'));
|
$this->show_form(_t('Nickname already in use. Try another one.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
list($display, $canonical, $sreg) = $this->get_saved_values();
|
list($display, $canonical, $sreg) = $this->get_saved_values();
|
||||||
|
|
||||||
if (!$display || !$canonical) {
|
if (!$display || !$canonical) {
|
||||||
common_server_error(_t('Stored OpenID not found.'));
|
common_server_error(_t('Stored OpenID not found.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Possible race condition... let's be paranoid
|
# Possible race condition... let's be paranoid
|
||||||
|
|
||||||
$other = oid_get_user($canonical);
|
$other = oid_get_user($canonical);
|
||||||
|
|
||||||
if ($other) {
|
if ($other) {
|
||||||
common_server_error(_t('Creating new account for OpenID that already has a user.'));
|
common_server_error(_t('Creating new account for OpenID that already has a user.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = new Profile();
|
$profile = new Profile();
|
||||||
|
|
||||||
$profile->nickname = $nickname;
|
$profile->nickname = $nickname;
|
||||||
|
|
||||||
if ($sreg['fullname'] && strlen($sreg['fullname']) <= 255) {
|
if ($sreg['fullname'] && strlen($sreg['fullname']) <= 255) {
|
||||||
$profile->fullname = $sreg['fullname'];
|
$profile->fullname = $sreg['fullname'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sreg['country']) {
|
if ($sreg['country']) {
|
||||||
if ($sreg['postcode']) {
|
if ($sreg['postcode']) {
|
||||||
# XXX: use postcode to get city and region
|
# XXX: use postcode to get city and region
|
||||||
@ -215,51 +215,51 @@ class FinishopenidloginAction extends Action {
|
|||||||
|
|
||||||
# XXX save language if it's passed
|
# XXX save language if it's passed
|
||||||
# XXX save timezone if it's passed
|
# XXX save timezone if it's passed
|
||||||
|
|
||||||
$profile->profileurl = common_profile_url($nickname);
|
$profile->profileurl = common_profile_url($nickname);
|
||||||
|
|
||||||
$profile->created = DB_DataObject_Cast::dateTime(); # current time
|
$profile->created = DB_DataObject_Cast::dateTime(); # current time
|
||||||
|
|
||||||
$id = $profile->insert();
|
$id = $profile->insert();
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
common_server_error(_t('Error saving the profile.'));
|
common_server_error(_t('Error saving the profile.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = new User();
|
$user = new User();
|
||||||
$user->id = $id;
|
$user->id = $id;
|
||||||
$user->nickname = $nickname;
|
$user->nickname = $nickname;
|
||||||
$user->uri = common_user_uri($user);
|
$user->uri = common_user_uri($user);
|
||||||
|
|
||||||
if ($sreg['email'] && Validate::email($sreg['email'], true)) {
|
if ($sreg['email'] && Validate::email($sreg['email'], true)) {
|
||||||
$user->email = $sreg['email'];
|
$user->email = $sreg['email'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$user->created = DB_DataObject_Cast::dateTime(); # current time
|
$user->created = DB_DataObject_Cast::dateTime(); # current time
|
||||||
|
|
||||||
$result = $user->insert();
|
$result = $user->insert();
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
# Try to clean up...
|
# Try to clean up...
|
||||||
$profile->delete();
|
$profile->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = oid_link_user($user->id, $canonical, $display);
|
$result = oid_link_user($user->id, $canonical, $display);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
# Try to clean up...
|
# Try to clean up...
|
||||||
$user->delete();
|
$user->delete();
|
||||||
$profile->delete();
|
$profile->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
oid_set_last($display);
|
oid_set_last($display);
|
||||||
common_set_user($user->nickname);
|
common_set_user($user->nickname);
|
||||||
common_real_login(true);
|
common_real_login(true);
|
||||||
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
|
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect_user() {
|
function connect_user() {
|
||||||
|
|
||||||
$nickname = $this->trimmed('nickname');
|
$nickname = $this->trimmed('nickname');
|
||||||
$password = $this->trimmed('password');
|
$password = $this->trimmed('password');
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ class FinishopenidloginAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# They're legit!
|
# They're legit!
|
||||||
|
|
||||||
$user = User::staticGet('nickname', $nickname);
|
$user = User::staticGet('nickname', $nickname);
|
||||||
|
|
||||||
list($display, $canonical, $sreg) = $this->get_saved_values();
|
list($display, $canonical, $sreg) = $this->get_saved_values();
|
||||||
@ -278,21 +278,21 @@ class FinishopenidloginAction extends Action {
|
|||||||
common_server_error(_t('Stored OpenID not found.'));
|
common_server_error(_t('Stored OpenID not found.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = oid_link_user($user->id, $canonical, $display);
|
$result = oid_link_user($user->id, $canonical, $display);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
common_server_error(_t('Error connecting user to OpenID.'));
|
common_server_error(_t('Error connecting user to OpenID.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
oid_update_user($user, $sreg);
|
oid_update_user($user, $sreg);
|
||||||
oid_set_last($display);
|
oid_set_last($display);
|
||||||
common_set_user($user->nickname);
|
common_set_user($user->nickname);
|
||||||
common_real_login(true);
|
common_real_login(true);
|
||||||
$this->go_home($user->nickname);
|
$this->go_home($user->nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
function go_home($nickname) {
|
function go_home($nickname) {
|
||||||
$url = common_get_returnto();
|
$url = common_get_returnto();
|
||||||
if ($url) {
|
if ($url) {
|
||||||
@ -305,9 +305,9 @@ class FinishopenidloginAction extends Action {
|
|||||||
}
|
}
|
||||||
common_redirect($url);
|
common_redirect($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function best_new_nickname($display, $sreg) {
|
function best_new_nickname($display, $sreg) {
|
||||||
|
|
||||||
# Try the passed-in nickname
|
# Try the passed-in nickname
|
||||||
|
|
||||||
|
|
||||||
@ -326,11 +326,11 @@ class FinishopenidloginAction extends Action {
|
|||||||
return $fullname;
|
return $fullname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Try the URL
|
# Try the URL
|
||||||
|
|
||||||
$from_url = $this->openid_to_nickname($display);
|
$from_url = $this->openid_to_nickname($display);
|
||||||
|
|
||||||
if ($from_url && $this->is_new_nickname($from_url)) {
|
if ($from_url && $this->is_new_nickname($from_url)) {
|
||||||
return $from_url;
|
return $from_url;
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ class FinishopenidloginAction extends Action {
|
|||||||
'max_length' => 64,
|
'max_length' => 64,
|
||||||
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!User::allowed_nickname($str)) {
|
if (!User::allowed_nickname($str)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -354,7 +354,7 @@ class FinishopenidloginAction extends Action {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openid_to_nickname($openid) {
|
function openid_to_nickname($openid) {
|
||||||
if (Auth_Yadis_identifierScheme($openid) == 'XRI') {
|
if (Auth_Yadis_identifierScheme($openid) == 'XRI') {
|
||||||
return $this->xri_to_nickname($openid);
|
return $this->xri_to_nickname($openid);
|
||||||
@ -426,7 +426,7 @@ class FinishopenidloginAction extends Action {
|
|||||||
return $this->nicknamize(array_pop($parts));
|
return $this->nicknamize(array_pop($parts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function xri_base($xri) {
|
function xri_base($xri) {
|
||||||
if (substr($xri, 0, 6) == 'xri://') {
|
if (substr($xri, 0, 6) == 'xri://') {
|
||||||
return substr($xri, 6);
|
return substr($xri, 6);
|
||||||
@ -436,7 +436,7 @@ class FinishopenidloginAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Given a string, try to make it work as a nickname
|
# Given a string, try to make it work as a nickname
|
||||||
|
|
||||||
function nicknamize($str) {
|
function nicknamize($str) {
|
||||||
$str = preg_replace('/\W/', '', $str);
|
$str = preg_replace('/\W/', '', $str);
|
||||||
return strtolower($str);
|
return strtolower($str);
|
||||||
|
@ -33,7 +33,7 @@ class ImsettingsAction extends SettingsAction {
|
|||||||
function show_form($msg=NULL, $success=false) {
|
function show_form($msg=NULL, $success=false) {
|
||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
$this->form_header(_t('IM Settings'), $msg, $success);
|
$this->form_header(_t('IM Settings'), $msg, $success);
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'imsettings',
|
'id' => 'imsettings',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('imsettings')));
|
common_local_url('imsettings')));
|
||||||
|
@ -65,7 +65,7 @@ class LoginAction extends Action {
|
|||||||
|
|
||||||
function show_form($error=NULL) {
|
function show_form($error=NULL) {
|
||||||
common_show_header(_t('Login'), NULL, $error, array($this, 'show_top'));
|
common_show_header(_t('Login'), NULL, $error, array($this, 'show_top'));
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'login',
|
'id' => 'login',
|
||||||
'action' => common_local_url('login')));
|
'action' => common_local_url('login')));
|
||||||
common_input('nickname', _t('Nickname'));
|
common_input('nickname', _t('Nickname'));
|
||||||
|
@ -59,7 +59,7 @@ class OpenidloginAction extends Action {
|
|||||||
function show_form($error=NULL, $openid_url) {
|
function show_form($error=NULL, $openid_url) {
|
||||||
common_show_header(_t('OpenID Login'), NULL, $error, array($this, 'show_top'));
|
common_show_header(_t('OpenID Login'), NULL, $error, array($this, 'show_top'));
|
||||||
$formaction = common_local_url('openidlogin');
|
$formaction = common_local_url('openidlogin');
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'openidlogin',
|
'id' => 'openidlogin',
|
||||||
'action' => $formaction));
|
'action' => $formaction));
|
||||||
common_input('openid_url', _t('OpenID URL'),
|
common_input('openid_url', _t('OpenID URL'),
|
||||||
|
@ -36,7 +36,7 @@ class OpenidsettingsAction extends SettingsAction {
|
|||||||
|
|
||||||
$this->form_header(_t('OpenID settings'), $msg, $success);
|
$this->form_header(_t('OpenID settings'), $msg, $success);
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'openidadd',
|
'id' => 'openidadd',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('openidsettings')));
|
common_local_url('openidsettings')));
|
||||||
|
@ -29,7 +29,7 @@ class PasswordAction extends SettingsAction {
|
|||||||
|
|
||||||
function show_form($msg=NULL, $success=false) {
|
function show_form($msg=NULL, $success=false) {
|
||||||
$this->form_header(_t('Change password'), $msg, $success);
|
$this->form_header(_t('Change password'), $msg, $success);
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'password',
|
'id' => 'password',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('password')));
|
common_local_url('password')));
|
||||||
|
@ -33,7 +33,7 @@ class ProfilesettingsAction extends SettingsAction {
|
|||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
$this->form_header(_t('Profile settings'), $msg, $success);
|
$this->form_header(_t('Profile settings'), $msg, $success);
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'profilesettings',
|
'id' => 'profilesettings',
|
||||||
'action' =>
|
'action' =>
|
||||||
common_local_url('profilesettings')));
|
common_local_url('profilesettings')));
|
||||||
|
@ -141,7 +141,7 @@ class RecoverpasswordAction extends Action {
|
|||||||
common_show_header(_t('Recover password'), NULL,
|
common_show_header(_t('Recover password'), NULL,
|
||||||
$msg, array($this, 'show_top'));
|
$msg, array($this, 'show_top'));
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'recoverpassword',
|
'id' => 'recoverpassword',
|
||||||
'action' => common_local_url('recoverpassword')));
|
'action' => common_local_url('recoverpassword')));
|
||||||
common_input('nicknameoremail', _t('Nickname or email'),
|
common_input('nicknameoremail', _t('Nickname or email'),
|
||||||
@ -158,7 +158,7 @@ class RecoverpasswordAction extends Action {
|
|||||||
common_show_header(_t('Reset password'), NULL,
|
common_show_header(_t('Reset password'), NULL,
|
||||||
$msg, array($this, 'show_password_top'));
|
$msg, array($this, 'show_password_top'));
|
||||||
|
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'recoverpassword',
|
'id' => 'recoverpassword',
|
||||||
'action' => common_local_url('recoverpassword')));
|
'action' => common_local_url('recoverpassword')));
|
||||||
common_password('newpassword', _t('New password'),
|
common_password('newpassword', _t('New password'),
|
||||||
|
@ -163,7 +163,7 @@ class RegisterAction extends Action {
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
common_show_header(_t('Register'), NULL, $error, array($this, 'show_top'));
|
common_show_header(_t('Register'), NULL, $error, array($this, 'show_top'));
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'login',
|
'id' => 'login',
|
||||||
'action' => common_local_url('register')));
|
'action' => common_local_url('register')));
|
||||||
common_input('nickname', _t('Nickname'), NULL,
|
common_input('nickname', _t('Nickname'), NULL,
|
||||||
|
@ -64,7 +64,7 @@ class RemotesubscribeAction extends Action {
|
|||||||
$profile = $this->trimmed('profile_url');
|
$profile = $this->trimmed('profile_url');
|
||||||
common_show_header(_t('Remote subscribe'), NULL, $err,
|
common_show_header(_t('Remote subscribe'), NULL, $err,
|
||||||
array($this, 'show_top'));
|
array($this, 'show_top'));
|
||||||
common_element_start('form', array('id' => 'remotesubscribe', 'method' => 'POST',
|
common_element_start('form', array('id' => 'remotesubscribe', 'method' => 'post',
|
||||||
'action' => common_local_url('remotesubscribe')));
|
'action' => common_local_url('remotesubscribe')));
|
||||||
common_input('nickname', _t('User nickname'), $nickname,
|
common_input('nickname', _t('User nickname'), $nickname,
|
||||||
_t('Nickname of the user you want to follow'));
|
_t('Nickname of the user you want to follow'));
|
||||||
|
@ -157,7 +157,7 @@ class ShowstreamAction extends StreamAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_subscribe_form($profile) {
|
function show_subscribe_form($profile) {
|
||||||
common_element_start('form', array('id' => 'subscribe', 'method' => 'POST',
|
common_element_start('form', array('id' => 'subscribe', 'method' => 'post',
|
||||||
'action' => common_local_url('subscribe')));
|
'action' => common_local_url('subscribe')));
|
||||||
common_element('input', array('id' => 'subscribeto',
|
common_element('input', array('id' => 'subscribeto',
|
||||||
'name' => 'subscribeto',
|
'name' => 'subscribeto',
|
||||||
@ -178,7 +178,7 @@ class ShowstreamAction extends StreamAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_unsubscribe_form($profile) {
|
function show_unsubscribe_form($profile) {
|
||||||
common_element_start('form', array('id' => 'unsubscribe', 'method' => 'POST',
|
common_element_start('form', array('id' => 'unsubscribe', 'method' => 'post',
|
||||||
'action' => common_local_url('unsubscribe')));
|
'action' => common_local_url('unsubscribe')));
|
||||||
common_element('input', array('id' => 'unsubscribeto',
|
common_element('input', array('id' => 'unsubscribeto',
|
||||||
'name' => 'unsubscribeto',
|
'name' => 'unsubscribeto',
|
||||||
|
@ -25,7 +25,7 @@ define('TIMESTAMP_THRESHOLD', 300);
|
|||||||
class UserauthorizationAction extends Action {
|
class UserauthorizationAction extends Action {
|
||||||
function handle($args) {
|
function handle($args) {
|
||||||
parent::handle($args);
|
parent::handle($args);
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
# We've shown the form, now post user's choice
|
# We've shown the form, now post user's choice
|
||||||
$this->send_authorization();
|
$this->send_authorization();
|
||||||
@ -36,7 +36,7 @@ class UserauthorizationAction extends Action {
|
|||||||
$argsclone = $_GET;
|
$argsclone = $_GET;
|
||||||
unset($argsclone['action']);
|
unset($argsclone['action']);
|
||||||
common_set_returnto(common_local_url('userauthorization', $argsclone));
|
common_set_returnto(common_local_url('userauthorization', $argsclone));
|
||||||
common_debug('userauthorization.php - redirecting to login');
|
common_debug('userauthorization.php - redirecting to login');
|
||||||
common_redirect(common_local_url('login'));
|
common_redirect(common_local_url('login'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ class UserauthorizationAction extends Action {
|
|||||||
common_server_error($e->getMessage());
|
common_server_error($e->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class UserauthorizationAction extends Action {
|
|||||||
$bio = $req->get_parameter('omb_listenee_bio');
|
$bio = $req->get_parameter('omb_listenee_bio');
|
||||||
$location = $req->get_parameter('omb_listenee_location');
|
$location = $req->get_parameter('omb_listenee_location');
|
||||||
$avatar = $req->get_parameter('omb_listenee_avatar');
|
$avatar = $req->get_parameter('omb_listenee_avatar');
|
||||||
|
|
||||||
common_show_header(_t('Authorize subscription'));
|
common_show_header(_t('Authorize subscription'));
|
||||||
common_element('p', NULL, _t('Please check these details to make sure '.
|
common_element('p', NULL, _t('Please check these details to make sure '.
|
||||||
'that you want to subscribe to this user\'s notices. '.
|
'that you want to subscribe to this user\'s notices. '.
|
||||||
@ -111,19 +111,19 @@ class UserauthorizationAction extends Action {
|
|||||||
$license);
|
$license);
|
||||||
common_element_end('div');
|
common_element_end('div');
|
||||||
common_element_end('div');
|
common_element_end('div');
|
||||||
common_element_start('form', array('method' => 'POST',
|
common_element_start('form', array('method' => 'post',
|
||||||
'id' => 'userauthorization',
|
'id' => 'userauthorization',
|
||||||
'name' => 'userauthorization',
|
'name' => 'userauthorization',
|
||||||
'action' => common_local_url('userauthorization')));
|
'action' => common_local_url('userauthorization')));
|
||||||
common_submit('accept', _t('Accept'));
|
common_submit('accept', _t('Accept'));
|
||||||
common_submit('reject', _t('Reject'));
|
common_submit('reject', _t('Reject'));
|
||||||
common_element_end('form');
|
common_element_end('form');
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function send_authorization() {
|
function send_authorization() {
|
||||||
$req = $this->get_stored_request();
|
$req = $this->get_stored_request();
|
||||||
|
|
||||||
if (!$req) {
|
if (!$req) {
|
||||||
common_user_error(_t('No authorization request!'));
|
common_user_error(_t('No authorization request!'));
|
||||||
return;
|
return;
|
||||||
@ -188,7 +188,7 @@ class UserauthorizationAction extends Action {
|
|||||||
$consumer_key = $req->get_parameter('oauth_consumer_key');
|
$consumer_key = $req->get_parameter('oauth_consumer_key');
|
||||||
$token_field = $req->get_parameter('oauth_token');
|
$token_field = $req->get_parameter('oauth_token');
|
||||||
common_debug('consumer key = "'.$consumer_key.'"', __FILE__);
|
common_debug('consumer key = "'.$consumer_key.'"', __FILE__);
|
||||||
common_debug('token field = "'.$token_field.'"', __FILE__);
|
common_debug('token field = "'.$token_field.'"', __FILE__);
|
||||||
$rt = new Token();
|
$rt = new Token();
|
||||||
$rt->consumer_key = $consumer_key;
|
$rt->consumer_key = $consumer_key;
|
||||||
$rt->tok = $token_field;
|
$rt->tok = $token_field;
|
||||||
@ -208,23 +208,23 @@ class UserauthorizationAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# XXX: refactor with similar code in finishremotesubscribe.php
|
# XXX: refactor with similar code in finishremotesubscribe.php
|
||||||
|
|
||||||
function save_remote_profile(&$req) {
|
function save_remote_profile(&$req) {
|
||||||
# FIXME: we should really do this when the consumer comes
|
# FIXME: we should really do this when the consumer comes
|
||||||
# back for an access token. If they never do, we've got stuff in a
|
# back for an access token. If they never do, we've got stuff in a
|
||||||
# weird state.
|
# weird state.
|
||||||
|
|
||||||
$nickname = $req->get_parameter('omb_listenee_nickname');
|
$nickname = $req->get_parameter('omb_listenee_nickname');
|
||||||
$fullname = $req->get_parameter('omb_listenee_fullname');
|
$fullname = $req->get_parameter('omb_listenee_fullname');
|
||||||
$profile_url = $req->get_parameter('omb_listenee_profile');
|
$profile_url = $req->get_parameter('omb_listenee_profile');
|
||||||
$homepage = $req->get_parameter('omb_listenee_homepage');
|
$homepage = $req->get_parameter('omb_listenee_homepage');
|
||||||
$bio = $req->get_parameter('omb_listenee_bio');
|
$bio = $req->get_parameter('omb_listenee_bio');
|
||||||
$location = $req->get_parameter('omb_listenee_location');
|
$location = $req->get_parameter('omb_listenee_location');
|
||||||
$avatar_url = $req->get_parameter('omb_listenee_avatar');
|
$avatar_url = $req->get_parameter('omb_listenee_avatar');
|
||||||
|
|
||||||
$listenee = $req->get_parameter('omb_listenee');
|
$listenee = $req->get_parameter('omb_listenee');
|
||||||
$remote = Remote_profile::staticGet('uri', $listenee);
|
$remote = Remote_profile::staticGet('uri', $listenee);
|
||||||
|
|
||||||
if ($remote) {
|
if ($remote) {
|
||||||
$exists = true;
|
$exists = true;
|
||||||
$profile = Profile::staticGet($remote->id);
|
$profile = Profile::staticGet($remote->id);
|
||||||
@ -239,7 +239,7 @@ class UserauthorizationAction extends Action {
|
|||||||
|
|
||||||
$profile->nickname = $nickname;
|
$profile->nickname = $nickname;
|
||||||
$profile->profileurl = $profile_url;
|
$profile->profileurl = $profile_url;
|
||||||
|
|
||||||
if ($fullname) {
|
if ($fullname) {
|
||||||
$profile->fullname = $fullname;
|
$profile->fullname = $fullname;
|
||||||
}
|
}
|
||||||
@ -252,7 +252,7 @@ class UserauthorizationAction extends Action {
|
|||||||
if ($location) {
|
if ($location) {
|
||||||
$profile->location = $location;
|
$profile->location = $location;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($exists) {
|
if ($exists) {
|
||||||
$profile->update($orig_profile);
|
$profile->update($orig_profile);
|
||||||
} else {
|
} else {
|
||||||
@ -291,11 +291,11 @@ class UserauthorizationAction extends Action {
|
|||||||
$sub->subscribed = $remote->id;
|
$sub->subscribed = $remote->id;
|
||||||
$sub->token = $token->key; # NOTE: request token, not valid for use!
|
$sub->token = $token->key; # NOTE: request token, not valid for use!
|
||||||
$sub->created = DB_DataObject_Cast::dateTime(); # current time
|
$sub->created = DB_DataObject_Cast::dateTime(); # current time
|
||||||
|
|
||||||
if (!$sub->insert()) {
|
if (!$sub->insert()) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,10 +304,10 @@ class UserauthorizationAction extends Action {
|
|||||||
copy($url, $temp_filename);
|
copy($url, $temp_filename);
|
||||||
return $profile->setOriginal($temp_filename);
|
return $profile->setOriginal($temp_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_accept_message($tok) {
|
function show_accept_message($tok) {
|
||||||
common_show_header(_t('Subscription authorized'));
|
common_show_header(_t('Subscription authorized'));
|
||||||
common_element('p', NULL,
|
common_element('p', NULL,
|
||||||
_t('The subscription has been authorized, but no '.
|
_t('The subscription has been authorized, but no '.
|
||||||
'callback URL was passed. Check with the site\'s instructions for '.
|
'callback URL was passed. Check with the site\'s instructions for '.
|
||||||
'details on how to authorize the subscription. Your subscription token is:'));
|
'details on how to authorize the subscription. Your subscription token is:'));
|
||||||
@ -317,25 +317,25 @@ class UserauthorizationAction extends Action {
|
|||||||
|
|
||||||
function show_reject_message($tok) {
|
function show_reject_message($tok) {
|
||||||
common_show_header(_t('Subscription rejected'));
|
common_show_header(_t('Subscription rejected'));
|
||||||
common_element('p', NULL,
|
common_element('p', NULL,
|
||||||
_t('The subscription has been rejected, but no '.
|
_t('The subscription has been rejected, but no '.
|
||||||
'callback URL was passed. Check with the site\'s instructions for '.
|
'callback URL was passed. Check with the site\'s instructions for '.
|
||||||
'details on how to fully reject the subscription.'));
|
'details on how to fully reject the subscription.'));
|
||||||
common_show_footer();
|
common_show_footer();
|
||||||
}
|
}
|
||||||
|
|
||||||
function store_request($req) {
|
function store_request($req) {
|
||||||
common_ensure_session();
|
common_ensure_session();
|
||||||
$_SESSION['userauthorizationrequest'] = $req;
|
$_SESSION['userauthorizationrequest'] = $req;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear_request() {
|
function clear_request() {
|
||||||
common_ensure_session();
|
common_ensure_session();
|
||||||
unset($_SESSION['userauthorizationrequest']);
|
unset($_SESSION['userauthorizationrequest']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_stored_request() {
|
function get_stored_request() {
|
||||||
common_ensure_session();
|
common_ensure_session();
|
||||||
$req = $_SESSION['userauthorizationrequest'];
|
$req = $_SESSION['userauthorizationrequest'];
|
||||||
return $req;
|
return $req;
|
||||||
}
|
}
|
||||||
@ -344,29 +344,29 @@ class UserauthorizationAction extends Action {
|
|||||||
$req = OAuthRequest::from_request();
|
$req = OAuthRequest::from_request();
|
||||||
return $req;
|
return $req;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Throws an OAuthException if anything goes wrong
|
# Throws an OAuthException if anything goes wrong
|
||||||
|
|
||||||
function validate_request(&$req) {
|
function validate_request(&$req) {
|
||||||
# OAuth stuff -- have to copy from OAuth.php since they're
|
# OAuth stuff -- have to copy from OAuth.php since they're
|
||||||
# all private methods, and there's no user-authentication method
|
# all private methods, and there's no user-authentication method
|
||||||
common_debug('checking version', __FILE__);
|
common_debug('checking version', __FILE__);
|
||||||
$this->check_version($req);
|
$this->check_version($req);
|
||||||
common_debug('getting datastore', __FILE__);
|
common_debug('getting datastore', __FILE__);
|
||||||
$datastore = omb_oauth_datastore();
|
$datastore = omb_oauth_datastore();
|
||||||
common_debug('getting consumer', __FILE__);
|
common_debug('getting consumer', __FILE__);
|
||||||
$consumer = $this->get_consumer($datastore, $req);
|
$consumer = $this->get_consumer($datastore, $req);
|
||||||
common_debug('getting token', __FILE__);
|
common_debug('getting token', __FILE__);
|
||||||
$token = $this->get_token($datastore, $req, $consumer);
|
$token = $this->get_token($datastore, $req, $consumer);
|
||||||
common_debug('checking timestamp', __FILE__);
|
common_debug('checking timestamp', __FILE__);
|
||||||
$this->check_timestamp($req);
|
$this->check_timestamp($req);
|
||||||
common_debug('checking nonce', __FILE__);
|
common_debug('checking nonce', __FILE__);
|
||||||
$this->check_nonce($datastore, $req, $consumer, $token);
|
$this->check_nonce($datastore, $req, $consumer, $token);
|
||||||
common_debug('checking signature', __FILE__);
|
common_debug('checking signature', __FILE__);
|
||||||
$this->check_signature($req, $consumer, $token);
|
$this->check_signature($req, $consumer, $token);
|
||||||
common_debug('validating omb stuff', __FILE__);
|
common_debug('validating omb stuff', __FILE__);
|
||||||
$this->validate_omb($req);
|
$this->validate_omb($req);
|
||||||
common_debug('done validating', __FILE__);
|
common_debug('done validating', __FILE__);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,9 +462,9 @@ class UserauthorizationAction extends Action {
|
|||||||
throw new OAuthException("Invalid callback URL '$callback'");
|
throw new OAuthException("Invalid callback URL '$callback'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Snagged from OAuthServer
|
# Snagged from OAuthServer
|
||||||
|
|
||||||
function check_version(&$req) {
|
function check_version(&$req) {
|
||||||
$version = $req->get_parameter("oauth_version");
|
$version = $req->get_parameter("oauth_version");
|
||||||
if (!$version) {
|
if (!$version) {
|
||||||
@ -477,13 +477,13 @@ class UserauthorizationAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Snagged from OAuthServer
|
# Snagged from OAuthServer
|
||||||
|
|
||||||
function get_consumer($datastore, $req) {
|
function get_consumer($datastore, $req) {
|
||||||
$consumer_key = @$req->get_parameter("oauth_consumer_key");
|
$consumer_key = @$req->get_parameter("oauth_consumer_key");
|
||||||
if (!$consumer_key) {
|
if (!$consumer_key) {
|
||||||
throw new OAuthException("Invalid consumer key");
|
throw new OAuthException("Invalid consumer key");
|
||||||
}
|
}
|
||||||
|
|
||||||
$consumer = $datastore->lookup_consumer($consumer_key);
|
$consumer = $datastore->lookup_consumer($consumer_key);
|
||||||
if (!$consumer) {
|
if (!$consumer) {
|
||||||
throw new OAuthException("Invalid consumer");
|
throw new OAuthException("Invalid consumer");
|
||||||
@ -492,7 +492,7 @@ class UserauthorizationAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Mostly cadged from OAuthServer
|
# Mostly cadged from OAuthServer
|
||||||
|
|
||||||
function get_token($datastore, &$req, $consumer) {/*{{{*/
|
function get_token($datastore, &$req, $consumer) {/*{{{*/
|
||||||
$token_field = @$req->get_parameter('oauth_token');
|
$token_field = @$req->get_parameter('oauth_token');
|
||||||
$token = $datastore->lookup_token($consumer, 'request', $token_field);
|
$token = $datastore->lookup_token($consumer, 'request', $token_field);
|
||||||
@ -501,7 +501,7 @@ class UserauthorizationAction extends Action {
|
|||||||
}
|
}
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_timestamp(&$req) {
|
function check_timestamp(&$req) {
|
||||||
$timestamp = @$req->get_parameter('oauth_timestamp');
|
$timestamp = @$req->get_parameter('oauth_timestamp');
|
||||||
$now = time();
|
$now = time();
|
||||||
@ -520,19 +520,19 @@ class UserauthorizationAction extends Action {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_signature(&$req, $consumer, $token) {
|
function check_signature(&$req, $consumer, $token) {
|
||||||
$signature_method = $this->get_signature_method($req);
|
$signature_method = $this->get_signature_method($req);
|
||||||
$signature = $req->get_parameter('oauth_signature');
|
$signature = $req->get_parameter('oauth_signature');
|
||||||
$valid_sig = $signature_method->check_signature($req,
|
$valid_sig = $signature_method->check_signature($req,
|
||||||
$consumer,
|
$consumer,
|
||||||
$token,
|
$token,
|
||||||
$signature);
|
$signature);
|
||||||
if (!$valid_sig) {
|
if (!$valid_sig) {
|
||||||
throw new OAuthException("Invalid signature");
|
throw new OAuthException("Invalid signature");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_signature_method(&$req) {
|
function get_signature_method(&$req) {
|
||||||
$signature_method = @$req->get_parameter("oauth_signature_method");
|
$signature_method = @$req->get_parameter("oauth_signature_method");
|
||||||
if (!$signature_method) {
|
if (!$signature_method) {
|
||||||
|
12
lib/util.php
12
lib/util.php
@ -219,7 +219,7 @@ function common_show_footer() {
|
|||||||
common_element_end('div'); # content div
|
common_element_end('div'); # content div
|
||||||
common_foot_menu();
|
common_foot_menu();
|
||||||
common_element_start('div', array('id' => 'footer'));
|
common_element_start('div', array('id' => 'footer'));
|
||||||
common_element_start('p', 'laconica');
|
common_element_start('div', 'laconica');
|
||||||
if (common_config('site', 'broughtby')) {
|
if (common_config('site', 'broughtby')) {
|
||||||
$instr = _t('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
|
$instr = _t('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%). ');
|
||||||
} else {
|
} else {
|
||||||
@ -232,7 +232,7 @@ function common_show_footer() {
|
|||||||
'(http://www.fsf.org/licensing/licenses/agpl-3.0.html).');
|
'(http://www.fsf.org/licensing/licenses/agpl-3.0.html).');
|
||||||
$output = common_markup_to_html($instr);
|
$output = common_markup_to_html($instr);
|
||||||
common_raw($output);
|
common_raw($output);
|
||||||
common_element_end('p');
|
common_element_end('div');
|
||||||
common_element('img', array('id' => 'cc',
|
common_element('img', array('id' => 'cc',
|
||||||
'src' => $config['license']['image'],
|
'src' => $config['license']['image'],
|
||||||
'alt' => $config['license']['title']));
|
'alt' => $config['license']['title']));
|
||||||
@ -393,7 +393,7 @@ function common_textarea($id, $label, $content=NULL, $instructions=NULL) {
|
|||||||
'cols' => 40,
|
'cols' => 40,
|
||||||
'name' => $id,
|
'name' => $id,
|
||||||
'id' => $id),
|
'id' => $id),
|
||||||
($content) ? $content : ' ');
|
($content) ? $content : '');
|
||||||
if ($instructions) {
|
if ($instructions) {
|
||||||
common_element('span', 'input_instructions', $instructions);
|
common_element('span', 'input_instructions', $instructions);
|
||||||
}
|
}
|
||||||
@ -830,14 +830,16 @@ function common_notice_form($action=NULL, $content=NULL) {
|
|||||||
$user = common_current_user();
|
$user = common_current_user();
|
||||||
assert(!is_null($user));
|
assert(!is_null($user));
|
||||||
common_element_start('form', array('id' => 'status_form',
|
common_element_start('form', array('id' => 'status_form',
|
||||||
'method' => 'POST',
|
'method' => 'post',
|
||||||
'action' => common_local_url('newnotice')));
|
'action' => common_local_url('newnotice')));
|
||||||
common_element_start('p');
|
common_element_start('p');
|
||||||
common_element('label', array('for' => 'status_update',
|
common_element('label', array('for' => 'status_textarea',
|
||||||
'id' => 'status_label'),
|
'id' => 'status_label'),
|
||||||
_t('What\'s up, ').$user->nickname.'?');
|
_t('What\'s up, ').$user->nickname.'?');
|
||||||
common_element('span', array('id' => 'counter', 'class' => 'counter'), '140');
|
common_element('span', array('id' => 'counter', 'class' => 'counter'), '140');
|
||||||
common_element('textarea', array('id' => 'status_textarea',
|
common_element('textarea', array('id' => 'status_textarea',
|
||||||
|
'cols' => 60,
|
||||||
|
'rows' => 3,
|
||||||
'name' => 'status_textarea'),
|
'name' => 'status_textarea'),
|
||||||
($content) ? $content : '');
|
($content) ? $content : '');
|
||||||
if ($action) {
|
if ($action) {
|
||||||
|
Loading…
Reference in New Issue
Block a user