Sha256: 47ea746c3ff62eb28162f0acd26444c9090ae75425d9e810c72e0821aeab87c7

Contents?: true

Size: 850 Bytes

Versions: 23

Compression:

Stored size: 850 Bytes

Contents

class PasswordResetsController < ApplicationController
  
  def create
    user = User.find_by_email(params[:email])
    if user
      user.send_password_reset
      redirect_to root_url, :notice => t('authentication.reset_password_email_sent_confirmation')
    else
      redirect_to root_url, :alert => t('authentication.warning.no_such_email')
    end
  end

  def edit
    @user = User.find_by_password_reset_token!(params[:id])
  end

  def update
    @user = User.find_by_password_reset_token!(params[:id])
    if @user.password_reset_sent_at < 24.hours.ago
      redirect_to new_password_reset_path, :alert => t('authentication.warning.password_reset_expired')
    elsif @user.update_attributes(params[:user])
      redirect_to root_url, :notice => t('authentication.password_reset_confirmation')
    else
      render :edit
    end
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
tkh_authentication-0.0.3 app/controllers/password_resets_controller.rb
tkh_authentication-0.0.2 app/controllers/password_resets_controller.rb
tkh_authentication-0.0.1 app/controllers/password_resets_controller.rb