Skip to content
Permalink
Browse files

Improve error handling in OpenID example

- properly check parameter types
- catch all exceptions (eg. network error)

Signed-off-by: Michal Čihař <michal@cihar.com>
  • Loading branch information...
nijel committed Jun 17, 2016
1 parent 00b9be9 commit 27664605b945b13e1d2b71adea822ace2099cc96
Showing with 3 additions and 3 deletions.
  1. +3 −3 examples/openid.php
@@ -98,9 +98,9 @@ function Show_page($contents)
}
/* Grab identifier */
if (isset($_POST['identifier'])) {
if (isset($_POST['identifier']) && is_string($_POST['identifier'])) {
$identifier = $_POST['identifier'];
} else if (isset($_SESSION['identifier'])) {
} else if (isset($_SESSION['identifier']) && is_string($_SESSION['identifier'])) {
$identifier = $_SESSION['identifier'];
} else {
$identifier = null;
@@ -109,7 +109,7 @@ function Show_page($contents)
/* Create OpenID object */
try {
$o = new OpenID_RelyingParty($returnTo, $realm, $identifier);
} catch (OpenID_Exception $e) {
} catch (Exception $e) {
$contents = "<div class='relyingparty_results'>\n";
$contents .= "<pre>" . $e->getMessage() . "</pre>\n";
$contents .= "</div class='relyingparty_results'>";

0 comments on commit 2766460

Please sign in to comment.
You can’t perform that action at this time.