Sha256: 73f0ee5ed3a49cc756bcbf94b8abcdb8e2c5cb4ecb33804c22f0ee865d6d2dd3

Contents?: true

Size: 1.44 KB

Versions: 10

Compression:

Stored size: 1.44 KB

Contents

class Admin::PasswordResetsController < Admin::ApplicationController

  before_filter :load_user_using_perishable_token, :only => [:show, :update]
  skip_before_filter :require_user, :require_admin_user
  layout 'admin/login'

  def index

  end

  def create
    @user = SpudUser.find_by_email(params[:email])
    if @user
      @user.reset_perishable_token!
      CoreMailer.forgot_password_notification(@user, admin_password_reset_url(@user.perishable_token)).deliver
      flash[:notice] = "Instructions to reset your password have been emailed to you. " +
      "Please check your email."
      redirect_to admin_login_path
    else
      flash.now[:error] = "No user was found with that email address"
      render 'index'
    end
  end

  def show

  end

  def update
    @user.password = params[:spud_user][:password]
    @user.password_confirmation = params[:spud_user][:password_confirmation]
    if @user.save
      flash[:notice] = "Password successfully updated"
      redirect_to admin_login_path
    else
      render 'show'
    end
  end

private

  def load_user_using_perishable_token
    @user = SpudUser.find_using_perishable_token(params[:id])
    unless @user
      flash[:notice] = "We're sorry, but we could not locate your account. " +
      "If you are having issues try copying and pasting the URL " +
      "from your email into your browser or restarting the " +
      "reset password process."
      redirect_to admin_login_path
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tb_core-1.2.1 app/controllers/admin/password_resets_controller.rb
tb_core-1.2.0 app/controllers/admin/password_resets_controller.rb
tb_core-1.1.10 app/controllers/admin/password_resets_controller.rb
tb_core-1.1.9 app/controllers/admin/password_resets_controller.rb
tb_core-1.1.8 app/controllers/admin/password_resets_controller.rb
tb_core-1.1.7 app/controllers/admin/password_resets_controller.rb
tb_core-1.1.6 app/controllers/admin/password_resets_controller.rb
tb_core-1.1.5 app/controllers/admin/password_resets_controller.rb
tb_core-1.1.4 app/controllers/admin/password_resets_controller.rb
tb_core-1.1.2 app/controllers/admin/password_resets_controller.rb