aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/user_controller.rb34
-rw-r--r--app/views/user/_signin.rhtml2
-rw-r--r--app/views/user/show.rhtml2
-rw-r--r--app/views/user/signchangepassword.rhtml (renamed from app/views/user/signchange.rhtml)4
-rw-r--r--app/views/user/signchangepassword_confirm.rhtml (renamed from app/views/user/signchange_confirm.rhtml)0
-rw-r--r--app/views/user/signchangepassword_send_confirm.rhtml (renamed from app/views/user/signchange_send_confirm.rhtml)10
-rw-r--r--config/routes.rb2
-rw-r--r--spec/controllers/user_controller_spec.rb20
8 files changed, 37 insertions, 37 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 01601bce6..7e942f32f 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -159,24 +159,24 @@ class UserController < ApplicationController
end
# Change password (XXX and perhaps later email) - requires email authentication
- def signchange
+ def signchangepassword
if @user and ((not session[:user_circumstance]) or (session[:user_circumstance] != "change_password"))
# Not logged in via email, so send confirmation
- params[:submitted_signchange_send_confirm] = true
- params[:signchange] = { :email => @user.email }
+ params[:submitted_signchangepassword_send_confirm] = true
+ params[:signchangepassword] = { :email => @user.email }
end
- if params[:submitted_signchange_send_confirm]
+ if params[:submitted_signchangepassword_send_confirm]
# They've entered the email, check it is OK and user exists
- if not MySociety::Validate.is_valid_email(params[:signchange][:email])
+ if not MySociety::Validate.is_valid_email(params[:signchangepassword][:email])
flash[:error] = "That doesn't look like a valid email address. Please check you have typed it correctly."
- render :action => 'signchange_send_confirm'
+ render :action => 'signchangepassword_send_confirm'
return
end
- user_signchange = User.find_user_by_email(params[:signchange][:email])
- if user_signchange
- # Send email with login link to go to signchange page
- url = signchange_url
+ user_signchangepassword = User.find_user_by_email(params[:signchangepassword][:email])
+ if user_signchangepassword
+ # Send email with login link to go to signchangepassword page
+ url = signchangepassword_url
if params[:pretoken]
url += "?pretoken=" + params[:pretoken]
end
@@ -188,27 +188,27 @@ class UserController < ApplicationController
},
:circumstance => "change_password" # special login that lets you change your password
)
- post_redirect.user = user_signchange
+ post_redirect.user = user_signchangepassword
post_redirect.save!
url = confirm_url(:email_token => post_redirect.email_token)
- UserMailer.deliver_confirm_login(user_signchange, post_redirect.reason_params, url)
+ UserMailer.deliver_confirm_login(user_signchangepassword, post_redirect.reason_params, url)
else
# User not found, but still show confirm page to not leak fact user exists
end
- render :action => 'signchange_confirm'
+ render :action => 'signchangepassword_confirm'
elsif not @user
# Not logged in, prompt for email
- render :action => 'signchange_send_confirm'
+ render :action => 'signchangepassword_send_confirm'
else
# Logged in via special email change password link, so can offer form to change password
raise "internal error" unless (session[:user_circumstance] == "change_password")
- if params[:submitted_signchange_password]
+ if params[:submitted_signchangepassword_do]
@user.password = params[:user][:password]
@user.password_confirmation = params[:user][:password_confirmation]
if not @user.valid?
- render :action => 'signchange'
+ render :action => 'signchangepassword'
else
@user.save!
flash[:notice] = "Your password has been changed."
@@ -220,7 +220,7 @@ class UserController < ApplicationController
end
end
else
- render :action => 'signchange'
+ render :action => 'signchangepassword'
end
end
end
diff --git a/app/views/user/_signin.rhtml b/app/views/user/_signin.rhtml
index 812bf9b4b..52c2a9e71 100644
--- a/app/views/user/_signin.rhtml
+++ b/app/views/user/_signin.rhtml
@@ -18,7 +18,7 @@
</p>
<p class="form_note">
- <%= link_to "Forgotten your password?", signchange_url + "?pretoken=" + h(params[:token]) %>
+ <%= link_to "Forgotten your password?", signchangepassword_url + "?pretoken=" + h(params[:token]) %>
</p>
<p class="form_checkbox">
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index 46ca8c751..2f9ecbcde 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -50,7 +50,7 @@
<%= link_to "Send message to " + h(@display_user.name), contact_user_url(:id => @display_user.id) %>
<% if @is_you %>
(just to see how it works)
- <br><%= link_to "Change your password", signchange_url() %>
+ <br><%= link_to "Change your password", signchangepassword_url() %>
<% end %>
</p>
diff --git a/app/views/user/signchange.rhtml b/app/views/user/signchangepassword.rhtml
index 032d80945..28a63709c 100644
--- a/app/views/user/signchange.rhtml
+++ b/app/views/user/signchangepassword.rhtml
@@ -4,7 +4,7 @@
<div id="change_password">
-<% form_tag({:action => "signchange"}, {:id => "signchange_form"}) do %>
+<% form_tag({:action => "signchangepassword"}, {:id => "signchangepassword_form"}) do %>
<%= foi_error_messages_for :user %>
<div class="form_note">
@@ -22,7 +22,7 @@
</p>
<div class="form_button">
- <%= hidden_field_tag 'submitted_signchange_password', 1 %>
+ <%= hidden_field_tag 'submitted_signchangepassword_do', 1 %>
<%= hidden_field_tag 'pretoken', params[:pretoken] %>
<%= submit_tag "Change password" %>
</div>
diff --git a/app/views/user/signchange_confirm.rhtml b/app/views/user/signchangepassword_confirm.rhtml
index baad6729b..baad6729b 100644
--- a/app/views/user/signchange_confirm.rhtml
+++ b/app/views/user/signchangepassword_confirm.rhtml
diff --git a/app/views/user/signchange_send_confirm.rhtml b/app/views/user/signchangepassword_send_confirm.rhtml
index e1462760c..2ff670c34 100644
--- a/app/views/user/signchange_send_confirm.rhtml
+++ b/app/views/user/signchangepassword_send_confirm.rhtml
@@ -2,16 +2,16 @@
<div id="change_password">
-<% form_tag({:action => "signchange"}, {:id => "signchange_form"}) do %>
- <%= foi_error_messages_for :signchange %>
+<% form_tag({:action => "signchangepassword"}, {:id => "signchangepassword_form"}) do %>
+ <%= foi_error_messages_for :signchangepassword %>
<div class="form_note">
<h1>Change your password</h1>
</div>
<p>
- <label class="form_label" for="signchange_email">Your e-mail:</label>
- <%= text_field 'signchange', 'email', { :size => 20 } %>
+ <label class="form_label" for="signchangepassword_email">Your e-mail:</label>
+ <%= text_field 'signchangepassword', 'email', { :size => 20 } %>
</p>
<p class="form_note">
@@ -21,7 +21,7 @@
</p>
<div class="form_button">
- <%= hidden_field_tag 'submitted_signchange_send_confirm', 1 %>
+ <%= hidden_field_tag 'submitted_signchangepassword_send_confirm', 1 %>
<%= hidden_field_tag 'pretoken', params[:pretoken] %>
<%= submit_tag "Submit" %>
</div>
diff --git a/config/routes.rb b/config/routes.rb
index 754d67da1..2b849a6e1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -56,7 +56,7 @@ ActionController::Routing::Routes.draw do |map|
user.signin '/signin', :action => 'signin'
user.signup '/signup', :action => 'signup'
user.signout '/signout', :action => 'signout'
- user.signchange '/signchange', :action => 'signchange'
+ user.signchangepassword '/signchangepassword', :action => 'signchangepassword'
user.confirm '/c/:email_token', :action => 'confirm'
user.show_user '/user/:url_name', :action => 'show'
user.contact_user '/user/contact/:id', :action => 'contact'
diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb
index 83abbfe3d..29658f085 100644
--- a/spec/controllers/user_controller_spec.rb
+++ b/spec/controllers/user_controller_spec.rb
@@ -240,14 +240,14 @@ describe UserController, "when changing password" do
fixtures :users
it "should show the email form when not logged in" do
- get :signchange
- response.should render_template('signchange_send_confirm')
+ get :signchangepassword
+ response.should render_template('signchangepassword_send_confirm')
end
it "should send a confirmation email when logged in normally" do
session[:user_id] = users(:bob_smith_user).id
- get :signchange
- response.should render_template('signchange_confirm')
+ get :signchangepassword
+ response.should render_template('signchangepassword_confirm')
deliveries = ActionMailer::Base.deliveries
deliveries.size.should == 1
@@ -258,15 +258,15 @@ describe UserController, "when changing password" do
it "should send a confirmation email when have wrong login circumstance" do
session[:user_id] = users(:bob_smith_user).id
session[:user_circumstance] = "bogus"
- get :signchange
- response.should render_template('signchange_confirm')
+ get :signchangepassword
+ response.should render_template('signchangepassword_confirm')
end
it "should show the password change screen when logged in as special password change mode" do
session[:user_id] = users(:bob_smith_user).id
session[:user_circumstance] = "change_password"
- get :signchange
- response.should render_template('signchange')
+ get :signchangepassword
+ response.should render_template('signchangepassword')
end
it "should change the password, if you have right to do so" do
@@ -274,8 +274,8 @@ describe UserController, "when changing password" do
session[:user_circumstance] = "change_password"
old_hash = users(:bob_smith_user).hashed_password
- post :signchange, { :user => { :password => 'ooo', :password_confirmation => 'ooo' },
- :submitted_signchange_password => 1
+ post :signchangepassword, { :user => { :password => 'ooo', :password_confirmation => 'ooo' },
+ :submitted_signchangepassword_do => 1
}
users(:bob_smith_user).hashed_password.should != old_hash