mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-30 20:55:17 +01:00
Some minor fixes and a change to the login system:
* RSS now has correct link for the context (fixes #144) * Pass a local variable to the _completed.rhtml partial so that the empty box gets the appropriate '...in this project' or '...in this context' description. * Added a checkbox 'Stay logged in' to the login page. When checked it prevents the session timing out after one hour of inactivity. You will stay logged in (with that browser) until you manually logout. That's useful for people who are using Tracks on a private machine to which only they have access. Addresses #20. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@177 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
c392296680
commit
a56b4611c8
5 changed files with 40 additions and 23 deletions
|
|
@ -38,17 +38,21 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def set_session_expiration
|
||||
# http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions
|
||||
return if @controller_name == 'feed'
|
||||
# If no session we don't care
|
||||
if @session
|
||||
# Get expiry time (allow ten seconds window for the case where we have none)
|
||||
expiry_time = @session['expiry_time'] || Time.now + 10
|
||||
if expiry_time < Time.now
|
||||
# Too late, matey... bang goes your session!
|
||||
reset_session
|
||||
else
|
||||
# Okay, you get another hour
|
||||
@session['expiry_time'] = Time.now + (60*60)
|
||||
unless @session == nil
|
||||
return if @controller_name == 'feed' or @session['noexpiry'] == "on"
|
||||
# If the method is called by the feed controller (which we don't have under session control)
|
||||
# or if we checked the box to keep logged in on login
|
||||
# don't set the session expiry time.
|
||||
if @session
|
||||
# Get expiry time (allow ten seconds window for the case where we have none)
|
||||
expiry_time = @session['expiry_time'] || Time.now + 10
|
||||
if expiry_time < Time.now
|
||||
# Too late, matey... bang goes your session!
|
||||
reset_session
|
||||
else
|
||||
# Okay, you get another hour
|
||||
@session['expiry_time'] = Time.now + (60*60)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +1,22 @@
|
|||
class LoginController < ApplicationController
|
||||
model :user
|
||||
layout 'login'
|
||||
skip_before_filter :set_session_expiration
|
||||
|
||||
def login
|
||||
@page_title = "Login"
|
||||
@page_title = "TRACKS::Login"
|
||||
case @request.method
|
||||
when :post
|
||||
if @session['user'] = User.authenticate(@params['user_login'], @params['user_password'])
|
||||
flash['notice'] = "Login successful"
|
||||
# If checkbox on login page checked, we don't expire the session after 1 hour
|
||||
# of inactivity
|
||||
@session['noexpiry']= @params['user_noexpiry']
|
||||
if @session['noexpiry'] == "on"
|
||||
msg = "will not expire."
|
||||
else
|
||||
msg = "will expire after 1 hour of inactivity."
|
||||
end
|
||||
flash['notice'] = "Login successful: session #{msg}"
|
||||
redirect_back_or_default :controller => "todo", :action => "list"
|
||||
else
|
||||
@login = @params['user_login']
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do
|
|||
xml.channel do
|
||||
xml.title("Tracks - Next Actions")
|
||||
xml.link("http://#{@request.host}:#{@request.port}/todo/list")
|
||||
xml.description("Lists the last 15 undone next actions")
|
||||
xml.description("Lists the last 15 uncompleted next actions")
|
||||
@not_done.each { |i|
|
||||
xml.item do
|
||||
xml.title(i.description)
|
||||
@link = url_for(:controller => 'context', :action => 'show', :id => "#{i.context_id}")
|
||||
@link = url_for(:controller => 'context', :action => 'show', :name => "#{i.context.name}")
|
||||
xml.link("http://#{@request.host}:#{@request.port}#{@link}")
|
||||
xml.description(i.context['name'])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,15 +12,19 @@
|
|||
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="user_login">Login:</label></td>
|
||||
<td><input type="text" name="user_login" id="user_login" size="20" value=""/></td>
|
||||
<td width="100px"><label for="user_login">Login:</label></td>
|
||||
<td width="100px"><input type="text" name="user_login" id="user_login" size="20" value=""/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="user_password">Password:</label></td>
|
||||
<td><input type="password" name="user_password" id="user_password" size="20"/></td>
|
||||
<tr>
|
||||
<td width="100px"><label for="user_password">Password:</label></td>
|
||||
<td width="100px"><input type="password" name="user_password" id="user_password" size="20"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<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" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100px"></td>
|
||||
<td><input type="submit" name="login" value="Login »" class="primary" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<div id="completed" class="items toggle_target">
|
||||
|
||||
<div id="empty-d" style="display:<%= @done.empty? ? 'block' : 'none' %>">
|
||||
<div class="message"><p>Currently there are no completed actions in this context</p></div>
|
||||
<div class="message"><p>Currently there are no completed actions <%= append_descriptor %></p></div>
|
||||
</div>
|
||||
|
||||
<%= render :partial => "todo/item", :collection => done %>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue