]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/users_controller.rb
Delete any outstanding tokens when a user changes their email
[rails.git] / app / controllers / users_controller.rb
index aa9a4f02aebd50bfc451c7d4ef0987718cd2cfe4..e5a57f47ef85439262c727db842570ede3d6a2b6 100644 (file)
@@ -146,11 +146,11 @@ class UsersController < ApplicationController
   def lost_password
     @title = t "users.lost_password.title"
 
-    if params[:user] && params[:user][:email]
-      user = User.visible.find_by(:email => params[:user][:email])
+    if params[:email]
+      user = User.visible.find_by(:email => params[:email])
 
       if user.nil?
-        users = User.visible.where("LOWER(email) = LOWER(?)", params[:user][:email])
+        users = User.visible.where("LOWER(email) = LOWER(?)", params[:email])
 
         user = users.first if users.count == 1
       end
@@ -359,14 +359,14 @@ class UsersController < ApplicationController
         gravatar_enabled = gravatar_enable(current_user)
         if current_user.save
           flash[:notice] = if gravatar_enabled
-                             t("users.confirm_email.success") + " " + gravatar_status_message(current_user)
+                             "#{t('users.confirm_email.success')} #{gravatar_status_message(current_user)}"
                            else
                              t("users.confirm_email.success")
                            end
         else
           flash[:errors] = current_user.errors
         end
-        token.destroy
+        current_user.tokens.delete_all
         session[:user] = current_user.id
         redirect_to :action => "account", :display_name => current_user.display_name
       elsif token
@@ -494,7 +494,7 @@ class UsersController < ApplicationController
   ##
   # omniauth failure callback
   def auth_failure
-    flash[:error] = t("users.auth_failure." + params[:message])
+    flash[:error] = t("users.auth_failure.#{params[:message]}")
     redirect_to params[:origin] || login_url
   end
 
@@ -524,7 +524,7 @@ class UsersController < ApplicationController
     if referer.nil?
       params[:origin] = request.path
     else
-      params[:origin] = request.path + "?referer=" + CGI.escape(referer)
+      params[:origin] = "#{request.path}?referer=#{CGI.escape(referer)}"
       params[:referer] = referer
     end
 
@@ -616,13 +616,13 @@ class UsersController < ApplicationController
     user.languages = params[:user][:languages].split(",")
 
     case params[:avatar_action]
-    when "new" then
+    when "new"
       user.avatar.attach(params[:user][:avatar])
       user.image_use_gravatar = false
-    when "delete" then
+    when "delete"
       user.avatar.purge_later
       user.image_use_gravatar = false
-    when "gravatar" then
+    when "gravatar"
       user.avatar.purge_later
       user.image_use_gravatar = true
     end