1 class PasswordsController < ApplicationController
 
   6   before_action :authorize_web
 
   7   before_action :set_locale
 
   8   before_action :check_database_readable
 
  10   authorize_resource :class => false
 
  12   before_action :check_database_writable
 
  22       self.current_user = User.find_by_token_for(:password_reset, params[:token])
 
  25         flash[:error] = t ".flash token bad"
 
  26         redirect_to :action => "new"
 
  34     user = User.visible.find_by(:email => params[:email])
 
  37       users = User.visible.where("LOWER(email) = LOWER(?)", params[:email])
 
  39       user = users.first if users.one?
 
  43       token = user.generate_token_for(:password_reset)
 
  44       UserMailer.lost_password(user, token).deliver_later
 
  47     flash[:notice] = t ".send_paranoid_instructions"
 
  48     redirect_to login_path
 
  53       self.current_user = User.find_by_token_for(:password_reset, params[:token])
 
  57           current_user.pass_crypt = params[:user][:pass_crypt]
 
  58           current_user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
 
  59           current_user.activate if current_user.may_activate?
 
  60           current_user.email_valid = true
 
  63             session[:fingerprint] = current_user.fingerprint
 
  64             flash[:notice] = t ".flash changed"
 
  65             successful_login(current_user)
 
  71         flash[:error] = t ".flash token bad"
 
  72         redirect_to :action => "new"