Created
November 14, 2011 10:23
-
-
Save roman-yepishev/1363682 to your computer and use it in GitHub Desktop.
Custom OpenID login page - see http://rtg.in.ua/2011/11/12/modauthopenid-and-ubuntu-sso/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html> | |
<head> | |
<title>Logging you via Ubuntu SSO</title> | |
<style type="text/css"> | |
body { font-family: sans-serif; font-size: 10pt; color: black; background-color: white; } | |
h1 { height: 32px; } | |
#errorMessage { border-left: 3px solid red; padding: 5px; margin: 10px 0; } | |
.hidden { display: none; } | |
.displayed { display: block; } | |
</style> | |
</head> | |
<body> | |
<h1>OpenID Login</h1> | |
<div id="errorMessage" class="hidden"></div> | |
<form action="/" method="GET"> | |
<input type="hidden" name="openid_identifier" | |
value="login.ubuntu.com"> | |
<input id="sb" type="submit" | |
value="Log in using Ubuntu SSO"> | |
</form> | |
<script type="text/javascript"> | |
function parseQueryString() { | |
var param = {} | |
var loc = location.href; | |
var qs_loc = loc.indexOf('?'); | |
if (qs_loc > -1) { | |
var sep = loc.indexOf(';') == -1 ? '&' : ';'; | |
var pairs = loc.substring(qs_loc+1).split(sep); | |
for (var i=0; i < pairs.length; i++) { | |
var kv = pairs[i].split('='); | |
param[kv[0]] = kv[1]; | |
} | |
} | |
return param; | |
} | |
function showError(message) { | |
var d = document.getElementById('errorMessage'); | |
d.innerHTML = 'Error: ' + message; | |
d.className = 'displayed'; | |
} | |
var qs = parseQueryString(); | |
if (qs['modauthopenid.referrer']) { | |
document.getElementsByTagName('form')[0].action = | |
decodeURIComponent(qs['modauthopenid.referrer']); | |
} | |
if (qs['modauthopenid.error']) { | |
showError(qs['modauthopenid.error']); | |
} | |
else { | |
document.getElementById('sb').className='hidden'; | |
document.getElementsByTagName('form')[0].submit(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment