class Public::PasswordResetsController < ApplicationController layout "public" def create customer = Customer.find_by_email(params[:email]) if customer 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 @customer = Customer.find_by_reset_password_token!(params[:id]) end def update @customer = Customer.find_by_reset_password_token!(params[:id]) if @customer.reset_password_sent_at < 2.hours.ago redirect_to new_public_password_reset_path, :alert => "La demande de réinitialisation à expirée." elsif @customer.update_attributes(params.require(: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