Class: BlueLightSpecial::SessionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/blue_light_special/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @user = if params[:session]
    ::User.authenticate(params[:session][:email], params[:session][:password])
  else
    ::User.find_facebook_user(cookies[BlueLightSpecial.configuration.facebook_api_key + "_session_key"],
                              cookies[BlueLightSpecial.configuration.facebook_api_key + "_user"])
  end
    
  if @user.nil?
    flash_failure_after_create
    render :template => 'sessions/new', :status => :unauthorized
  else
    (@user)
    flash_success_after_create
    redirect_back_or(url_after_create)
  end
end

#destroyObject



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

def destroy
  if BlueLightSpecial.configuration.use_facebook_connect
    cookies[BlueLightSpecial.configuration.facebook_api_key + "_user"] = nil
    cookies[BlueLightSpecial.configuration.facebook_api_key + "_session_key"] = nil
  end
  sign_out
  flash_success_after_destroy
  redirect_to(url_after_destroy)
end

#newObject



8
9
10
# File 'app/controllers/blue_light_special/sessions_controller.rb', line 8

def new
  render :template => 'sessions/new'
end