Class: Compartment::Admin::SessionsController

Inherits:
Compartment::ApplicationController show all
Defined in:
app/controllers/compartment/admin/sessions_controller.rb

Instance Attribute Summary

Attributes inherited from Compartment::ApplicationController

#current_site

Instance Method Summary collapse

Methods inherited from Compartment::ApplicationController

#find_site_by_domain

Instance Method Details

#createObject



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

def create
  if params[:email].empty? or params[:password].empty?
    flash.now.alert = "Invalid email or password"
    return render "new"
  end

  user = current_site.users.find_by_email(params[:email])
  if user && user.authenticate(params[:password])
    session[:user_id] = user.id
    redirect_to admin_dashboard_url, :notice => "Logged in!"
  else
    flash.now.alert = "Invalid email or password"
    render "new"
  end
end

#destroyObject



28
29
30
31
# File 'app/controllers/compartment/admin/sessions_controller.rb', line 28

def destroy
  session[:user_id] = nil
  redirect_to root_url, :notice => "Logged out!"
end

#newObject



9
10
# File 'app/controllers/compartment/admin/sessions_controller.rb', line 9

def new
end