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 token = UserToken.find_by(:token => params[:token])
25 self.current_user = token.user
27 flash[:error] = t ".flash token bad"
28 redirect_to :action => "new"
36 user = User.visible.find_by(:email => params[:email])
39 users = User.visible.where("LOWER(email) = LOWER(?)", params[:email])
41 user = users.first if users.count == 1
45 token = user.tokens.create
46 UserMailer.lost_password(user, token).deliver_later
47 flash[:notice] = t ".notice email on way"
48 redirect_to login_path
50 flash.now[:error] = t ".notice email cannot find"
57 token = UserToken.find_by(:token => params[:token])
60 self.current_user = token.user
63 current_user.pass_crypt = params[:user][:pass_crypt]
64 current_user.pass_crypt_confirmation = params[:user][:pass_crypt_confirmation]
65 current_user.activate if current_user.may_activate?
66 current_user.email_valid = true
70 session[:fingerprint] = current_user.fingerprint
71 flash[:notice] = t ".flash changed"
72 successful_login(current_user)
78 flash[:error] = t ".flash token bad"
79 redirect_to :action => "new"