Class: PasswordController

Inherits:
BaseController show all
Defined in:
app/controllers/password_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#site

Instance Method Summary collapse

Methods included from ResourceHelper

#current_controller_namespace, #links_to_actions, #normalize_resource_link_options, #normalize_resource_link_text, #normalize_resource_type, #resource_delete_options, #resource_link, #resource_link_id, #resource_owners, #resource_url, #resource_url_method, #resource_url_namespace

Methods included from ContentHelper

#content_category_checkbox, #content_path, #content_status, #link_to_category, #link_to_content, #link_to_preview, #link_to_tag, #links_to_content_categories, #links_to_content_tags, #page_link_path, #published_at_formatted

Methods included from CacheableFlash

included, #write_flash_to_cookie

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/password_controller.rb', line 8

def create
  flash[:notice] = t(:'adva.passwords.flash.create.notification')
  if user = User.find_by_email(params[:user][:email])
    token = user.assign_token 'password'
    user.save!
    trigger_event user, :password_reset_requested, :token => "#{user.id};#{token}"
    redirect_to edit_password_url
  else
    render :action => :new
  end
end

#editObject



20
21
# File 'app/controllers/password_controller.rb', line 20

def edit
end

#newObject



5
6
# File 'app/controllers/password_controller.rb', line 5

def new
end

#updateObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/password_controller.rb', line 23

def update
  if current_user && current_user.update(params[:user].slice(:password))
    trigger_event current_user, :password_updated
    flash[:notice] = t(:'adva.passwords.flash.update.success')
    authenticate_user(:email => current_user.email, :password => params[:user][:password])
    redirect_to "/"
  else
    params[:token] = nil # ugh
    flash[:error] = t(:'adva.passwords.flash.update.failure')
    render :action => :edit
  end
end