kaps_app/app/controllers/public/password_resets_controller.rb
Nicolas Bally d60301e8a7 initial
2019-01-21 01:15:10 +01:00

30 lines
988 B
Ruby
Executable File

class Public::PasswordResetsController < ApplicationController
layout "public"
def create
p_customer = PCustomer.find_by_email(params[:email])
if p_customer
p_customer.send_password_reset
redirect_to public_my_account_path, :notice => "Un email vous a été envoyé avec les instructions pour la mise à jour."
else
render :action => :new
end
end
def edit
@p_customer = PCustomer.find_by_reset_password_token!(params[:id])
end
def update
@p_customer = PCustomer.find_by_reset_password_token!(params[:id])
if @p_customer.reset_password_sent_at < 2.hours.ago
redirect_to new_public_password_reset_path, :alert => "La demande de réinitialisation à expirée."
elsif @p_customer.update_attributes(params.require(:p_customer).permit(:password, :password_confirmation))
redirect_to public_my_account_path, :notice => "Le mot de passe à été réinitialisé."
else
render :edit
end
end
end