Skip to content

Instantly share code, notes, and snippets.

@ianbarber
Created July 29, 2013 15:01
Show Gist options
  • Save ianbarber/6104941 to your computer and use it in GitHub Desktop.
Save ianbarber/6104941 to your computer and use it in GitHub Desktop.
X-Has-Session example
<html><head>
<title>OpenID X-Has-Session</title>
</head>
<body>
<div id="msg"></div>
<script>
if (window.location.href.indexOf("openid.mode=") != -1) {
if (window.location.href.indexOf("x-has-session") != -1) {
document.getElementById("msg").textContent = "You be logged in";
} else {
document.getElementById("msg").textContent = "You be logged out";
}
} else {
var page = window.location.href;
var url = "https://accounts.google.com/o/openid2/auth?openid.mode=checkid_immediate&openid.ui.mode=x-has-session&openid.ns=http://specs.openid.net/auth/2.0&openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.ns.ui=http://specs.openid.net/extensions/ui/1.0&openid.return_to=" + page;
// Redirect the user.
window.location.href = url;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment