Class: LeanCms::PasswordsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/lean_cms/passwords_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
# File 'app/controllers/lean_cms/passwords_controller.rb', line 12

def create
  user_class = LeanCms.user_class.constantize

  if user = user_class.find_by(email_address: params[:email_address])
    LeanCms::PasswordsMailer.reset(user).deliver_later
  end

  redirect_to lean_cms_new_session_path, notice: "Password reset instructions sent (if user with that email address exists)."
end

#editObject



22
23
# File 'app/controllers/lean_cms/passwords_controller.rb', line 22

def edit
end

#newObject



9
10
# File 'app/controllers/lean_cms/passwords_controller.rb', line 9

def new
end

#updateObject



25
26
27
28
29
30
31
32
# File 'app/controllers/lean_cms/passwords_controller.rb', line 25

def update
  if @user.update(params.permit(:password, :password_confirmation))
    LeanCms::Session.where(user: @user).destroy_all
    redirect_to lean_cms_new_session_path, notice: "Password has been reset."
  else
    redirect_to lean_cms_edit_password_path(params[:token]), alert: "Passwords did not match."
  end
end