Class: PasswordController

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

Instance Attribute Summary

Attributes inherited from BaseController

#section, #site

Instance Method Summary collapse

Methods included from Adva::AuthenticateUser

#authenticate_user, #authenticated?, #current_user, included

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

Instance Method Details

#createObject



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

def create
  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, notice: "If the given email address exists in our system, we have just sent you an email with information on how to reset your password."
  else
    render :action => :new
  end
end

#editObject



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

def edit
end

#newObject



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

def new
end

#updateObject



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

def update
  if current_user && current_user.update(params[:user].slice(:password))
    trigger_event current_user, :password_updated
    authenticate_user(:email => current_user.email, :password => params[:user][:password])
    redirect_to "/", notice: "Your password was changed successfully."
  else
    params[:token] = nil # ugh
    flash.now.alert = "Your password could not be changed."
    render :action => :edit
  end
end