Module: TinyCore::Controllers::PasswordResets

Defined in:
lib/tiny_core/controllers/password_resets.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



4
5
6
7
# File 'lib/tiny_core/controllers/password_resets.rb', line 4

def self.included(receiver)
  receiver.before_filter :load_user_using_perishable_token, :only => [:edit, :update]
  receiver.before_filter :guest_required
end

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tiny_core/controllers/password_resets.rb', line 17

def create
  @user = User.find_by_email(params[:email])
  if @user
    @user.deliver_password_reset_instructions!
    flash[:notice] = I18n.t("flash.notice.password_instructions_sent")
    redirect_to password_resets_path
  else
    flash[:error] = I18n.t("flash.error.user_by_email_not_found")
    render :action => :new
  end
end

#editObject



29
30
31
# File 'lib/tiny_core/controllers/password_resets.rb', line 29

def edit
  render
end

#indexObject



9
10
11
# File 'lib/tiny_core/controllers/password_resets.rb', line 9

def index
  render
end

#newObject



13
14
15
# File 'lib/tiny_core/controllers/password_resets.rb', line 13

def new
  render
end

#updateObject



33
34
35
36
37
38
39
40
# File 'lib/tiny_core/controllers/password_resets.rb', line 33

def update
  if @user.reset_password!(params[:user][:password], params[:user][:password_confirmation])
    flash[:notice] = I18n.t("flash.notice.password_updated")
    redirect_to root_path
  else
    render :action => :edit
  end
end