aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/user_controller.rb
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-03-10 03:15:25 +0000
committerFrancis Irving <francis@mysociety.org>2010-03-10 03:15:25 +0000
commit2734ede2a66553bf29294d64f9c1ed9782324686 (patch)
tree8097fc7c7bec5552d9de9dbb04e3a270a4a0fccc /app/controllers/user_controller.rb
parent5e752e09c4d5afe4150bf20cc5ef332b1d8cda1a (diff)
Form for changing your email address
Diffstat (limited to 'app/controllers/user_controller.rb')
-rw-r--r--app/controllers/user_controller.rb36
1 files changed, 35 insertions, 1 deletions
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 7e942f32f..ec0afc214 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -147,10 +147,13 @@ class UserController < ApplicationController
end
# Logout form
- def signout
+ def _do_signout
session[:user_id] = nil
session[:user_circumstance] = nil
session[:remember_me] = false
+ end
+ def signout
+ self._do_signout
if params[:r]
redirect_to params[:r]
else
@@ -225,6 +228,37 @@ class UserController < ApplicationController
end
end
+ # Change your email
+ def signchangeemail
+ if not authenticated?(
+ :web => "To change your email address",
+ :email => "Then you can change your email address",
+ :email_subject => "Change your email address"
+ )
+ # "authenticated?" has done the redirect to signin page for us
+ return
+ end
+
+ work_out_post_redirect
+
+ if params[:submitted_signchangeemail_do]
+ @signchangeemail = ChangeEmailValidator.new(params[:signchangeemail])
+ @signchangeemail.logged_in_user = @user
+
+ if @signchangeemail.valid?
+ @user.email = @signchangeemail.new_email
+ @user.email_confirmed = false
+ @user.save!
+ self._do_signout
+ flash[:notice] = "Your email has been changed."
+ send_confirmation_mail @user
+ return
+ end
+ end
+
+ render :action => 'signchangeemail'
+ end
+
# Send a message to another user
def contact
@recipient_user = User.find(params[:id])