From: Tom Hughes Date: Wed, 13 Aug 2008 11:44:53 +0000 (+0000) Subject: Don't user flash[:notice] when we're not redirecting as it will X-Git-Tag: live~7709 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/967f44ffac7dfbbc91dabd8dc221be22e4ba0606?hp=64ecd02f0b74d2251e30fc1c97fdf1aa60f53e90 Don't user flash[:notice] when we're not redirecting as it will persist to the next request and cause confusion. --- diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 26c56132c..2bb4eb577 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -45,13 +45,11 @@ class UserController < ApplicationController if @user.save if params[:user][:email] == @user.new_email - flash[:notice] = "User information updated successfully. Check your email for a note to confirm your new email address." + @notice = "User information updated successfully. Check your email for a note to confirm your new email address." Notifier.deliver_email_confirm(@user, @user.tokens.create) else - flash[:notice] = "User information updated successfully." + @notice = "User information updated successfully." end - else - flash.delete(:notice) end end end @@ -81,12 +79,10 @@ class UserController < ApplicationController if user token = user.tokens.create Notifier.deliver_lost_password(user, token) - flash[:notice] = "Sorry you lost it :-( but an email is on its way so you can reset it soon." + @notice = "Sorry you lost it :-( but an email is on its way so you can reset it soon." else - flash[:notice] = "Couldn't find that email address, sorry." + @notice = "Couldn't find that email address, sorry." end - else - render :action => 'lost_password' end end @@ -109,6 +105,7 @@ class UserController < ApplicationController flash[:notice] = "Didn't find that token, check the URL maybe?" end end + redirect_to :action => 'login' end @@ -131,9 +128,9 @@ class UserController < ApplicationController end return elsif User.authenticate(:username => email_or_display_name, :password => pass, :inactive => true) - flash[:notice] = "Sorry, your account is not active yet.
Please click on the link in the account confirmation email to activate your account." + @notice = "Sorry, your account is not active yet.
Please click on the link in the account confirmation email to activate your account." else - flash[:notice] = "Sorry, couldn't log in with those details." + @notice = "Sorry, couldn't log in with those details." end end end @@ -167,7 +164,7 @@ class UserController < ApplicationController session[:user] = @user.id redirect_to :action => 'account', :display_name => @user.display_name else - flash[:notice] = 'Something went wrong confirming that user.' + @notice = 'Something went wrong confirming that user.' end end end @@ -187,7 +184,7 @@ class UserController < ApplicationController session[:user] = @user.id redirect_to :action => 'account', :display_name => @user.display_name else - flash[:notice] = 'Something went wrong confirming that email address.' + @notice = 'Something went wrong confirming that email address.' end end end @@ -244,6 +241,7 @@ class UserController < ApplicationController else flash[:notice] = "You are already friends with #{name}." end + redirect_to :controller => 'user', :action => 'view' end end @@ -258,9 +256,8 @@ class UserController < ApplicationController else flash[:notice] = "#{friend.display_name} was not already one of your friends." end + redirect_to :controller => 'user', :action => 'view' end end - end - diff --git a/app/views/layouts/site.rhtml b/app/views/layouts/site.rhtml index 4b41e5e9e..7aa2db7b9 100644 --- a/app/views/layouts/site.rhtml +++ b/app/views/layouts/site.rhtml @@ -11,8 +11,8 @@
- <% if flash[:notice] %> -
<%= flash[:notice] %>
+ <% if @notice || flash[:notice] %> +
<%= @notice || flash[:notice] %>
<% end %> <%= yield %>