Class: UserSessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/user_sessions_controller.rb

Instance Method Summary collapse

Methods inherited from Spud::ApplicationController

#not_found

Methods included from TbCore::ApplicationHelper

#cache_key_for_spud_collection, #current_site_name, #tb_form_error_field, #tb_form_error_header, #tb_form_errors, #tb_form_field, #tb_form_for, #tb_page_title

Instance Method Details

#change_passwordObject



39
40
41
# File 'app/controllers/user_sessions_controller.rb', line 39

def change_password
  render 'change_password'
end

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/user_sessions_controller.rb', line 14

def create
  @user_session = SpudUserSession.new(params[:spud_user_session])
  logged_in = @user_session.save()
  respond_with @user_session do |format|
    format.html{
      if logged_in
        flash[:notice] = "Login successful!"
        redirect_back_or_default('/')
      else
        render 'new'
      end
    }
  end
end

#destroyObject



29
30
31
32
33
34
35
36
37
# File 'app/controllers/user_sessions_controller.rb', line 29

def destroy
  current_user_session.destroy unless current_user_session.blank?
  respond_with({}) do |format|
    format.html{
      flash[:notice] = "Logout successful!"
      redirect_back_or_default()
    }
  end
end

#newObject



9
10
11
12
# File 'app/controllers/user_sessions_controller.rb', line 9

def new
  @user_session = SpudUserSession.new
  render 'new'
end

#set_change_passwordObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/user_sessions_controller.rb', line 43

def set_change_password
  current_user.update_attributes(change_password_params)
  respond_with current_user do |format|
    format.html{
      if current_user.errors.any?
        render 'change_password'
      else
        redirect_back_or_default('/')
      end
    }
  end
end