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



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

def change_password
  render 'change_password'
end

#createObject



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

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



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

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



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

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

#set_change_passwordObject



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

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