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]) ||
23 UserToken.unexpired.find_by(:token => params[:token])&.user
26 flash[:error] = t ".flash token bad"
27 redirect_to :action => "new"
35 user = User.visible.find_by(:email => params[:email])
38 users = User.visible.where("LOWER(email) = LOWER(?)", params[:email])
40 user = users.first if users.count == 1
44 token = user.generate_token_for(:password_reset)
45 UserMailer.lost_password(user, token).deliver_later
48 flash[:notice] = t ".send_paranoid_instructions"
49 redirect_to login_path
54 self.current_user = User.find_by_token_for(:password_reset, params[:token]) ||
55 UserToken.unexpired.find_by(:token => params[:token])&.user
59 current_user.pass_crypt = params[:user][:pass_crypt]
60 current_user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
61 current_user.activate if current_user.may_activate?
62 current_user.email_valid = true
65 UserToken.delete_by(:token => params[:token])
66 session[:fingerprint] = current_user.fingerprint
67 flash[:notice] = t ".flash changed"
68 successful_login(current_user)
74 flash[:error] = t ".flash token bad"
75 redirect_to :action => "new"