mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 22:41:48 +01:00
Clean up login screen when database authentication AND open id authentication is enabled.
There's now a simple way to switch between forms rather than showing them both at once. Plus, Tracks will cookie you when you switch forms so it remembers the last type of authentication you used when you return. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@504 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
e0787cd627
commit
2485faaf5c
4 changed files with 100 additions and 53 deletions
|
|
@ -4,14 +4,7 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<%= stylesheet_link_tag "scaffold" %>
|
||||
<%= javascript_include_tag :defaults %>
|
||||
<script type="text/javascript">
|
||||
function setfocus() {
|
||||
var f = $('user_login');
|
||||
if (!f) { f = $('openid_url'); }
|
||||
if (f) { f.focus() };
|
||||
}
|
||||
Event.observe(window, 'load', setfocus);
|
||||
</script>
|
||||
|
||||
<title><%= @page_title -%></title>
|
||||
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -1,52 +1,78 @@
|
|||
<% auth_schemes = Tracks::Config.auth_schemes -%>
|
||||
<% auth_schemes = Tracks::Config.auth_schemes
|
||||
show_database_form = auth_schemes.include?('database')
|
||||
show_openid_form = auth_schemes.include?('open_id')
|
||||
-%>
|
||||
|
||||
<div title="Account login" id="loginform" class="form">
|
||||
|
||||
<%= render_flash %>
|
||||
|
||||
<h3>Please log in to use Tracks:</h3>
|
||||
|
||||
<% if auth_schemes.include?('database') || auth_schemes.include?('open_id') %>
|
||||
<% form_tag :action=> 'login' do %>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_login">Login:</label></td>
|
||||
<td width="100px"><input type="text" name="user_login" id="user_login" value="" class="login_text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_password">Password:</label></td>
|
||||
<td width="100px"><input type="password" name="user_password" id="user_password" class="login_text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_noexpiry">Stay logged in:</label></td>
|
||||
<td width="100px"><input type="checkbox" name="user_noexpiry" id="user_noexpiry" checked /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"></td>
|
||||
<td><input type="submit" name="login" value="Login »" class="primary" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if show_database_form %>
|
||||
<div id="database_auth_form" style="display:block">
|
||||
<% form_tag :action=> 'login' do %>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_login">Login:</label></td>
|
||||
<td width="100px"><input type="text" name="user_login" id="user_login" value="" class="login_text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_password">Password:</label></td>
|
||||
<td width="100px"><input type="password" name="user_password" id="user_password" class="login_text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_noexpiry">Stay logged in:</label></td>
|
||||
<td width="100px"><input type="checkbox" name="user_noexpiry" id="user_noexpiry" checked /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"></td>
|
||||
<td><input type="submit" name="login" value="Sign In »" class="primary" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if auth_schemes.include?('open_id') %>
|
||||
<% form_tag :action=> 'login', :action => 'begin' do %>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="100px"><label for="openid_url">Identity URL:</label></td>
|
||||
<td width="100px"><input type="text" name="openid_url" id="openid_url" value="<%= @openid_url %>" class="login_text open_id" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_noexpiry">Stay logged in:</label></td>
|
||||
<td width="100px"><input type="checkbox" name="user_noexpiry" id="user_noexpiry" checked /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"></td>
|
||||
<td><input type="submit" name="login" value="Verify »" class="primary" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if show_openid_form %>
|
||||
<div id="openid_auth_form" style="display:none">
|
||||
<% form_tag :action=> 'login', :action => 'begin' do %>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="100px"><label for="openid_url">Identity URL:</label></td>
|
||||
<td width="100px"><input type="text" name="openid_url" id="openid_url" value="<%= @openid_url %>" class="login_text open_id" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_noexpiry">Stay logged in:</label></td>
|
||||
<td width="100px"><input type="checkbox" name="user_noexpiry" id="user_noexpiry" checked /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"></td>
|
||||
<td><input type="submit" name="login" value="Sign In »" class="primary" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<% if show_openid_form %><p id="alternate_auth_openid" class="alternate_auth">or, <a href="#" onclick="Login.showOpenid();return false;">login with an OpenId</a></p><% end %>
|
||||
<% if show_database_form %><p id="alternate_auth_database" class="alternate_auth">or, <a href="#" onclick="Login.showDatabase();return false;">go back to the standard login</a></p><% end %>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function showPreferredAuth() {
|
||||
var preferredAuth = new CookieManager().getCookie('preferred_auth');
|
||||
var databaseEnabled = <%= show_database_form ? 'true' : 'false' %>;
|
||||
var openidEnabled = <%= show_openid_form ? 'true' : 'false' %>;
|
||||
if (preferredAuth && preferredAuth == 'openid' && openidEnabled) {
|
||||
Login.showOpenid();
|
||||
}
|
||||
else if (databaseEnabled) {
|
||||
Login.showDatabase();
|
||||
}
|
||||
else if (openidEnabled) {
|
||||
Login.showOpenid();
|
||||
}
|
||||
}
|
||||
Event.observe(window, 'load', showPreferredAuth);
|
||||
</script>
|
||||
|
|
@ -1,3 +1,25 @@
|
|||
var Login = {
|
||||
showOpenid: function() {
|
||||
if ($('database_auth_form')) $('database_auth_form').hide();
|
||||
if ($('openid_auth_form')) $('openid_auth_form').show();
|
||||
if ($('alternate_auth_openid')) $('alternate_auth_openid').hide();
|
||||
if ($('alternate_auth_database')) $('alternate_auth_database').show();
|
||||
if ($('openid_url')) $('openid_url').focus();
|
||||
if ($('openid_url')) $('openid_url').select();
|
||||
new CookieManager().setCookie('preferred_auth', 'openid');
|
||||
},
|
||||
|
||||
showDatabase: function(container) {
|
||||
if ($('openid_auth_form')) $('openid_auth_form').hide();
|
||||
if ($('database_auth_form')) $('database_auth_form').show();
|
||||
if ($('alternate_auth_database')) $('alternate_auth_database').hide();
|
||||
if ($('alternate_auth_openid')) $('alternate_auth_openid').show();
|
||||
if ($('user_login')) $('user_login').focus();
|
||||
if ($('user_login')) $('user_login').select();
|
||||
new CookieManager().setCookie('preferred_auth', 'database');
|
||||
}
|
||||
}
|
||||
|
||||
Ajax.Responders.register({
|
||||
onCreate: function() {
|
||||
if($('busy') && Ajax.activeRequestCount>0)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ td {background-color: #ff9;}
|
|||
|
||||
div.form {
|
||||
width: 350px;
|
||||
margin: 100px auto;
|
||||
margin: 100px auto 10px auto;
|
||||
padding: 10px;
|
||||
border: 1px solid #999;
|
||||
background: #ff9;
|
||||
|
|
@ -153,4 +153,10 @@ input.open_id {
|
|||
color: #000;
|
||||
padding-left: 18px;
|
||||
width:182px;
|
||||
}
|
||||
}
|
||||
p.alternate_auth {
|
||||
text-align:center;
|
||||
}
|
||||
p.alternate_auth a {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue