aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/application.rb43
-rw-r--r--app/views/user_accounts/signin.rhtml14
-rw-r--r--todo.txt7
3 files changed, 32 insertions, 32 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index c0f158187..f665d6c4b 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application.rb,v 1.12 2007-10-10 16:06:17 francis Exp $
+# $Id: application.rb,v 1.13 2007-10-11 13:21:31 francis Exp $
class ApplicationController < ActionController::Base
@@ -20,34 +20,33 @@ class ApplicationController < ActionController::Base
def signin
# The explict signin link uses this to store where it is to go back to
if params[:r]
- session[:request_uri] = params[:r]
+ session[:intended_uri] = params[:r]
+ session[:intended_params] = nil
end
if not params[:user]
# First time page is shown
render :template => 'user_accounts/signin' and return
- elsif params[:returning] == "0"
- # "I am new to FOIFA"
- session[:email] = params[:user][:email]
- redirect_to :action => 'signup' and return
- elsif params[:returning] == "1"
- # "I am returning to FOIFA and my password is"
+ else
@user = User.authenticate(params[:user][:email], params[:user][:password])
if @user
# Successful login
session[:user] = @user.id
post_redirect session[:intended_uri], session[:intended_params] and return
else
- # Failed to authenticate
- flash[:error] = "Email or password not correct, please try again"
+ if User.find(:first, :conditions => [ "email = ?", params[:user][:email] ])
+ # Failed to authenticate
+ flash[:error] = "Password not correct, please try again"
+ @user = User.new(params[:user])
+ render :template => 'user_accounts/signin' and return
+ else
+ # "I am new to FOIFA"
+ session[:email] = params[:user][:email]
+ session[:password] = params[:user][:password]
+ session[:first_time] = true
+ redirect_to :action => 'signup' and return
+ end
end
- @user = User.new(params[:user])
- render :template => 'user_accounts/signin' and return
- else
- # Form submitted, but didn't specify whether had already used FOIFA or not
- flash[:error] = "Please say whether you already have a FOIFA account or not"
- @user = User.new(params[:user])
- render :template => 'user_accounts/signin' and return
end
end
@@ -55,10 +54,18 @@ class ApplicationController < ActionController::Base
def signup
# Default to value saved from signin form
params[:user] ||= { :email => session[:email] }
+ params[:user] ||= { :password => session[:password] }
# Make the user and try to save it
@user = User.new(params[:user])
if not @user.save
+ # First time get to form (e.g. from signin) , don't show errors
+ if session[:first_time]
+ @first_time = true
+ @user.errors.clear
+ session[:first_time] = false
+ end
+ # Show the form
render :template => 'user_accounts/signup'
else
# New user made, redirect back to where we were
@@ -118,7 +125,7 @@ class ApplicationController < ActionController::Base
# If we are in a redirect to POST request, then set params
before_filter :check_in_post_redirect
def check_in_post_redirect
- if params[:post_redirect]
+ if params[:post_redirect] and session[:post_redirect_params]
params.update(session[:post_redirect_params])
end
end
diff --git a/app/views/user_accounts/signin.rhtml b/app/views/user_accounts/signin.rhtml
index b93088559..d390c7174 100644
--- a/app/views/user_accounts/signin.rhtml
+++ b/app/views/user_accounts/signin.rhtml
@@ -7,19 +7,13 @@
</p>
<p>
- <%= radio_button_tag 'returning', 0, params[:returning] == "0" %>
- <label for="returning_0" class="radio_label"><strong>I am new to FOIFA</strong></label>
- </p>
-
- <p>
- <%= radio_button_tag 'returning', 1, params[:returning] == "1" %>
- <label for="returning_1" class="radio_label"><strong>I am returning to FOIFA and
- my password is:</strong></label>
+ <label for="user_password"><strong>Password:</strong></label>
+ <%= password_field 'user', 'password', { :size => 15 } %>
</p>
<p>
- <label for="user_password">&nbsp;</label>
- <%= password_field 'user', 'password', { :size => 15 } %>
+ <label>&nbsp;</label>
+ Don't have a password? Just enter one to register a new account.
</p>
<p>
diff --git a/todo.txt b/todo.txt
index 251719ff3..4dbf334d7 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,7 +1,9 @@
Try making login just go username/password always
Ghost out password field when radio not selected on signin.rhtml
+
Use something other than session for post redirect store, so can go via email
-Show that you are logged in in top right corner
+If you recently made a request, then a login will try to make it again because
+ all the stuff for the post redirect is in the session. Consider again
Send confirmation email
@@ -12,9 +14,6 @@ Make it say "dear" as default letter
Write some tests (try it their way, at every level)
-Go through all controllers and make sure index URL works
-After signin, should go back to full URL with ids etc. as well
-
Tidying
=======