Class: SessionsController

Inherits:
Devise::SessionsController
  • Object
show all
Defined in:
lib/forge/app/controllers/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/forge/app/controllers/sessions_controller.rb', line 8

def create
  resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")
  if resource.approved?
    (resource_name, resource)
    respond_with resource, :location => (resource)
  else
    Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
    set_flash_message :warning, :not_approved
    redirect_to "/login"
  end
end

#destroyObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/forge/app/controllers/sessions_controller.rb', line 20

def destroy
  signed_in = signed_in?(resource_name)
  Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name)
  set_flash_message :notice, :signed_out if signed_in

  respond_to do |format|
    format.any(*navigational_formats) { redirect_to "/login" }
    format.all do
      method = "to_#{request_format}"
      text = {}.respond_to?(method) ? {}.send(method) : ""
      render :text => text, :status => :ok
    end
  end
end

#newObject



2
3
4
5
6
# File 'lib/forge/app/controllers/sessions_controller.rb', line 2

def new
  self.resource = resource_class.new()
  clean_up_passwords(resource)
  render :template => "devise/sessions/new"
end