Class: Headstart::SessionsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/headstart/sessions_controller.rb', line 13

def create
  @user = if params[:session]
    ::User.authenticate(params[:session][:email], params[:session][:password])
  else
    ::User.find_facebook_user(params['code'], get_full_app_path)
  end
    
  if @user.nil?
    flash_failure_after_create
    render :template => Headstart.configuration.session_failure_template, :status => :unauthorized
  else
    if @user.email_confirmed?
      flash_success_after_create
    elsif @user.email_confirmation_sent_at.blank?
      ::HeadstartMailer.deliver_welcome(@user)
      @user.update_attribute(:email_confirmation_sent_at, Time.now)
      flash_notice_after_create
    end
    (@user)
    reset_session
    redirect_back_or(url_after_create)
  end
end

#destroyObject



37
38
39
40
41
42
43
44
45
# File 'app/controllers/headstart/sessions_controller.rb', line 37

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

#newObject



9
10
11
# File 'app/controllers/headstart/sessions_controller.rb', line 9

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