require_login(); // POST overrides GET $openid = require_post("openid", require_get("openid", require_post("openid_manual", require_get("openid_manual", false)))); if ($openid && !is_string($openid)) { throw new Exception("Invalid openid parameter"); } $messages = array(); $errors = array(); // try logging in? try { if ($openid) { $user = \Users\User::getInstance(db()); $args = array("openid" => $openid); $redirect = absolute_url(url_for('openid_add', $args)); try { $identity = \Users\UserOpenID::addIdentity(db(), $user, $openid, $redirect); $messages[] = t("Added OpenID identity ':identity' to your account.", array(':identity' => htmlspecialchars($identity))); // redirect $destination = url_for('user#user_openid'); set_temporary_messages($messages); set_temporary_errors($errors); redirect($destination); } catch (\Users\UserSignupException $e) { $errors[] = $e->getMessage(); } } } catch (Exception $e) { if (!$e instanceof EscapedException) { $e = new EscapedException(htmlspecialchars($e->getMessage()), (int) $e->getCode(), $e); } $errors[] = $e->getMessage();