]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_controller.rb
Explicitly specify the format when expiring RSS feeds
[rails.git] / app / controllers / user_controller.rb
index 3f5eef831be43329199f9d48a25753f11686b207..89f35a8996e6cea3c9b20808259ae16b76e8d0b2 100644 (file)
@@ -166,9 +166,10 @@ class UserController < ApplicationController
         @user.preferred_editor = params[:user][:preferred_editor]
       end
 
-      @user.openid_url = nil if params[:user][:openid_url].empty?
+      @user.openid_url = nil if params[:user][:openid_url].blank?
 
-      if params[:user][:openid_url].length > 0 and
+      if params[:user][:openid_url] and
+         params[:user][:openid_url].length > 0 and
          params[:user][:openid_url] != @user.openid_url
         # If the OpenID has changed, we want to check that it is a
         # valid OpenID and one the user has control over before saving
@@ -200,7 +201,15 @@ class UserController < ApplicationController
     @title = t 'user.lost_password.title'
 
     if params[:user] and params[:user][:email]
-      user = User.visible.where(:email => params[:user][:email]).first
+      user = User.visible.find_by_email(params[:user][:email])
+
+      if user.nil?
+        users = User.visible.where("LOWER(email) = LOWER(?)", params[:user][:email])
+
+        if users.count == 1
+          user = users.first
+        end
+      end
 
       if user
         token = user.tokens.create
@@ -273,6 +282,8 @@ class UserController < ApplicationController
       else
         password_authentication(params[:username], params[:password])
       end
+    elsif params[:notice]
+      flash.now[:notice] = t "user.login.notice_#{params[:notice]}"
     elsif flash[:notice].nil?
       flash.now[:notice] =  t 'user.login.notice'
     end