25 lines
849 B
Ruby
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 |