Class: Gemgento::User::SessionsController

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

Instance Method Summary collapse

Instance Method Details

#create {|resource| ... } ⇒ Object

POST /resource/sign_in

Yields:

  • (resource)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/gemgento/user/sessions_controller.rb', line 7

def create
  self.resource = warden.authenticate!(auth_options)
  set_flash_message(:notice, :signed_in) if is_flashing_format?
  (resource_name, resource)
  yield resource if block_given?

  respond_to do |format|
    format.html { respond_with resource, location: (resource) }
    format.json do
      render json: {
          result: true,
          user: resource,
          csrfParam: request_forgery_protection_token,
          csrfToken: form_authenticity_token
      }
    end
  end
end

#destroyObject

DELETE /resource/sign_out



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/gemgento/user/sessions_controller.rb', line 27

def destroy
  redirect_path = after_sign_out_path_for(resource_name)
  signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
  set_flash_message :notice, :signed_out if signed_out && is_navigational_format?

  # reset the current quote when user logs out, the current quotes persists between user sessions.
  current_quote.reset unless current_quote.new_record?

  # We actually need to hardcode this as Rails default responder doesn't
  # support returning empty response on GET request
  respond_to do |format|
    format.all { head :no_content }
    format.any(*navigational_formats) { redirect_to redirect_path }
  end
end