diff --git a/plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php b/plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php index 68679f53bf..876443aa3f 100644 --- a/plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php +++ b/plugins/DomainStatusNetwork/DomainStatusNetworkPlugin.php @@ -196,6 +196,23 @@ class DomainStatusNetworkPlugin extends Plugin return true; } + static function userExists($email) + { + $domain = self::toDomain($email); + + $sn = self::siteForDomain($domain); + + if (empty($sn)) { + return false; + } + + StatusNet::switchSite($sn->nickname); + + $user = User::staticGet('email', $email); + + return !empty($user); + } + static function registerEmail($email, $sendWelcome, $template) { $domain = self::toDomain($email); @@ -221,6 +238,50 @@ class DomainStatusNetworkPlugin extends Plugin return $confirm; } + + static function login($email, $password) + { + $domain = self::toDomain($email); + + $sn = self::siteForDomain($domain); + + if (empty($sn)) { + throw new ClientException(_("No such site.")); + } + + StatusNet::switchSite($sn->nickname); + + $user = common_check_user($email, $password); + + if (empty($user)) { + // TRANS: Form validation error displayed when trying to log in with incorrect credentials. + throw new ClientException(_('Incorrect username or password.')); + } + + $loginToken = Login_token::makeNew($user); + + if (empty($loginToken)) { + throw new ServerException(_('Cannot log in.')); + } + + $url = common_local_url('otp', array('user_id' => $loginToken->user_id, + 'token' => $loginToken->token)); + + return $url; + } + + static function recoverPassword($email) + { + $domain = self::toDomain($email); + + $sn = self::siteForDomain($domain); + + if (empty($sn)) { + throw new NoSuchUserException(array('email' => $email)); + } + + StatusNet::switchSite($sn->nickname); + } // The way addPlugin() works, this global variable gets disappeared. diff --git a/plugins/DomainStatusNetwork/actions/globallogin.php b/plugins/DomainStatusNetwork/actions/globallogin.php new file mode 100644 index 0000000000..034d719a2f --- /dev/null +++ b/plugins/DomainStatusNetwork/actions/globallogin.php @@ -0,0 +1,76 @@ +. + * + * @category DomainStatusNetwork + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Class comment + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class GlobalLoginAction extends Action +{ + /** + * For initializing members of the class. + * + * @param array $argarray misc. arguments + * + * @return boolean true + */ + + function prepare($argarray) + { + parent::prepare($argarray); + return true; + } + + /** + * Handler method + * + * @param array $argarray is ignored since it's now passed in in prepare() + * + * @return void + */ + + function handle($argarray=null) + { + return; + } +} diff --git a/plugins/DomainStatusNetwork/actions/globalregister.php b/plugins/DomainStatusNetwork/actions/globalregister.php new file mode 100644 index 0000000000..ad223808ff --- /dev/null +++ b/plugins/DomainStatusNetwork/actions/globalregister.php @@ -0,0 +1,118 @@ +. + * + * @category DomainStatusNetwork + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET')) { + // This check helps protect against security problems; + // your code file can't be executed directly from the web. + exit(1); +} + +/** + * Class comment + * + * @category Action + * @package StatusNet + * @author Evan Prodromou + * @copyright 2011 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0 + * @link http://status.net/ + */ + +class GlobalRegisterAction extends Action +{ + /** + * For initializing members of the class. + * + * @param array $argarray misc. arguments + * + * @return boolean true + */ + + function prepare($argarray) + { + parent::prepare($argarray); + return true; + } + + /** + * Handler method + * + * @param array $argarray is ignored since it's now passed in in prepare() + * + * @return void + */ + + function handle($argarray=null) + { + return; + } + + /** + * Return true if read only. + * + * MAY override + * + * @param array $args other arguments + * + * @return boolean is read only action? + */ + + function isReadOnly($args) + { + return false; + } + + /** + * Return last modified, if applicable. + * + * MAY override + * + * @return string last modified http header + */ + function lastModified() + { + // For comparison with If-Last-Modified + // If not applicable, return null + return null; + } + + /** + * Return etag, if applicable. + * + * MAY override + * + * @return string etag http header + */ + + function etag() + { + return null; + } +}