]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/passwords_controller.rb
Merge remote-tracking branch 'upstream/pull/4271'
[rails.git] / app / controllers / passwords_controller.rb
index 331575964aba6abaec47a8ade9467ae4504b2186..08df9f7a4bbeed964c17af62ccc7c4a5263c5cfb 100644 (file)
@@ -12,7 +12,7 @@ class PasswordsController < ApplicationController
   before_action :check_database_writable, :only => [:lost_password, :reset_password]
 
   def lost_password
   before_action :check_database_writable, :only => [:lost_password, :reset_password]
 
   def lost_password
-    @title = t "passwords.lost_password.title"
+    @title = t ".title"
 
     if request.post?
       user = User.visible.find_by(:email => params[:email])
 
     if request.post?
       user = User.visible.find_by(:email => params[:email])
@@ -26,16 +26,16 @@ class PasswordsController < ApplicationController
       if user
         token = user.tokens.create
         UserMailer.lost_password(user, token).deliver_later
       if user
         token = user.tokens.create
         UserMailer.lost_password(user, token).deliver_later
-        flash[:notice] = t "passwords.lost_password.notice email on way"
+        flash[:notice] = t ".notice email on way"
         redirect_to login_path
       else
         redirect_to login_path
       else
-        flash.now[:error] = t "passwords.lost_password.notice email cannot find"
+        flash.now[:error] = t ".notice email cannot find"
       end
     end
   end
 
   def reset_password
       end
     end
   end
 
   def reset_password
-    @title = t "passwords.reset_password.title"
+    @title = t ".title"
 
     if params[:token]
       token = UserToken.find_by(:token => params[:token])
 
     if params[:token]
       token = UserToken.find_by(:token => params[:token])
@@ -46,18 +46,18 @@ class PasswordsController < ApplicationController
         if params[:user]
           current_user.pass_crypt = params[:user][:pass_crypt]
           current_user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
         if params[:user]
           current_user.pass_crypt = params[:user][:pass_crypt]
           current_user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
-          current_user.status = "active" if current_user.status == "pending"
+          current_user.activate if current_user.may_activate?
           current_user.email_valid = true
 
           if current_user.save
             token.destroy
             session[:fingerprint] = current_user.fingerprint
           current_user.email_valid = true
 
           if current_user.save
             token.destroy
             session[:fingerprint] = current_user.fingerprint
-            flash[:notice] = t "passwords.reset_password.flash changed"
+            flash[:notice] = t ".flash changed"
             successful_login(current_user)
           end
         end
       else
             successful_login(current_user)
           end
         end
       else
-        flash[:error] = t "passwords.reset_password.flash token bad"
+        flash[:error] = t ".flash token bad"
         redirect_to :action => "lost_password"
       end
     else
         redirect_to :action => "lost_password"
       end
     else