Sha256: dd884457a71f0681c5e9c42dc43b735f27982b6570bd37330c349bd51939cf6a

Contents?: true

Size: 1.55 KB

Versions: 20

Compression:

Stored size: 1.55 KB

Contents

class PasswordsController < ::Devise::PasswordsController
  layout 'login'

  # Rather than overriding devise, it seems better to just apply the notice here.
  after_filter :give_notice, :only => [:update]
  def give_notice
    unless %w(notice error alert).include?(flash.keys.map(&:to_s)) or @user.errors.any?
      flash[:notice] = t('successful', :scope => 'users.reset', :email => @user.email)
    end
  end
  protected :give_notice

  # GET /registrations/password/edit?reset_password_token=abcdef
  def edit
    if params[:reset_password_token] and (@user = User.find_by_reset_password_token(params[:reset_password_token])).present?
      render_with_scope :edit
    else
      redirect_to(new_user_password_url, :flash => ({
        :error => t('code_invalid', :scope => 'users.reset')
      }))
    end
  end

  # POST /registrations/password
  def create
    if params[:user].present? and (email = params[:user][:email]).present? and
       (user = User.find_by_email(email)).present?

      # Call devise reset function.
      user.send(:generate_reset_password_token!)
      UserMailer.reset_notification(user, request).deliver
      redirect_to new_user_session_path, :notice => t('email_reset_sent', :scope => 'users.forgot') and return
    else
      @user = User.new(params[:user])
      flash.now[:error] = if (email = params[:user][:email]).blank?
        t('blank_email', :scope => 'users.forgot')
      else
        t('email_not_associated_with_account_html', :email => email, :scope => 'users.forgot').html_safe
      end
      render_with_scope :new
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
refinerycms-authentication-0.9.9.21 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.20 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.19 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.18 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.17 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.16 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.15 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.14 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.13 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.12 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.11 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.10 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.9 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.8 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.7 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.5 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.4 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.3 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.2 app/controllers/passwords_controller.rb
refinerycms-authentication-0.9.9.1 app/controllers/passwords_controller.rb