From 99f2aba6e164795035326f3520979e70c22d1f10 Mon Sep 17 00:00:00 2001 From: Chimo Date: Wed, 24 Feb 2016 12:42:41 -0500 Subject: [PATCH] Fix: Cannot remove OpenID OpenidsettingsAction::removeOpenID() was comparing and int with a string so always displayed "That OpenID does not belong to you." --- plugins/OpenID/actions/openidsettings.php | 2 +- plugins/OpenID/classes/User_openid.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/OpenID/actions/openidsettings.php b/plugins/OpenID/actions/openidsettings.php index bf5d8886f1..75835ff1f1 100644 --- a/plugins/OpenID/actions/openidsettings.php +++ b/plugins/OpenID/actions/openidsettings.php @@ -287,7 +287,7 @@ class OpenidsettingsAction extends SettingsAction // TRANS: Form validation error for a non-existing OpenID. throw new ClientException(_m('No such OpenID.')); } - if ($this->scoped->getID() !== $oid->user_id) { + if ($this->scoped->getID() !== $oid->getID()) { // TRANS: Form validation error if OpenID is connected to another user. throw new ClientException(_m('That OpenID does not belong to you.')); } diff --git a/plugins/OpenID/classes/User_openid.php b/plugins/OpenID/classes/User_openid.php index 7e53d8ec95..2221a9e78a 100644 --- a/plugins/OpenID/classes/User_openid.php +++ b/plugins/OpenID/classes/User_openid.php @@ -45,6 +45,16 @@ class User_openid extends Managed_DataObject ); } + public function getID() + { + if (!isset($this->user_id)) { + throw new Exception('No ID set.'); + } elseif (empty($this->user_id)) { + throw new Exception('Empty ID for object! (not inserted yet?).'); + } + return intval($this->user_id); + } + static function hasOpenID($user_id) { $oid = new User_openid();