musifrat_app/app/controllers/admin/password_resets_controller.rb
Nicolas Bally a1aef72f7f intial
2019-02-03 15:12:58 +01:00

25 lines
849 B
Ruby

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