2011-03-27 22:56:15 +02:00
|
|
|
class MailerController < ApplicationController
|
|
|
|
|
2014-02-17 18:05:39 +01:00
|
|
|
def resetpassword
|
|
|
|
# protect against bots
|
|
|
|
render :text => '' and return if params[:userlogin].length > 0
|
2012-02-10 00:42:16 +01:00
|
|
|
|
2014-02-17 18:05:39 +01:00
|
|
|
@user = User.find_by_login_or_email(params[:user][:login])
|
|
|
|
if @user.nil?
|
|
|
|
sleep 2
|
|
|
|
session[:mail_message] = t(:account_not_found)
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
@user.reset_perishable_token!
|
|
|
|
Mailer.password_reset(@user, "#{RESET_PASSWORD_URL}#{@user.id}?token=#{@user.perishable_token}").deliver
|
|
|
|
session[:mail_message] = t(:password_reset_mailed)
|
|
|
|
rescue
|
|
|
|
session[:mail_message] = t(:password_reset_error)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
redirect_to login_path
|
|
|
|
end
|
2011-03-27 22:56:15 +02:00
|
|
|
|
|
|
|
end
|