Sha256: f24c2cb9f2a0bd65c9c0b1c644b9fbf47382cd9dbdd189560c587ff5b9a45c80
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
module Clearance module App module Controllers module PasswordsController def self.included(base) base.class_eval do before_filter :find_user_with_reset_password_code_or_deny, :only => [:edit, :update] filter_parameter_logging :password, :password_confirmation include InstanceMethods private include PrivateInstanceMethods end end module InstanceMethods def create user = User.find_by_email params[:email] if user.nil? flash.now[:error] = 'Unknown email' render :action => :new else user.generate_reset_password_code ClearanceMailer.deliver_forgot_password user redirect_to url_after_create end end def update if @user.reset_password(params) session[:user_id] = @user.id redirect_to @user else flash.now[:error] = 'Password not changed.' render :action => :edit end end end module PrivateInstanceMethods def find_user_with_reset_password_code_or_deny @user = User.find_by_reset_password_code(params[:id]) if @user.nil? render :nothing => true, :status => :not_found end end def url_after_create new_session_url end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hashrocket-clearance-0.4.0 | lib/clearance/app/controllers/passwords_controller.rb |
hashrocket-clearance-0.4.1 | lib/clearance/app/controllers/passwords_controller.rb |