Class: Contour::SessionsController
- Inherits:
-
Devise::SessionsController
- Object
- Devise::SessionsController
- Contour::SessionsController
- Defined in:
- app/controllers/contour/sessions_controller.rb
Instance Method Summary collapse
-
#create {|resource| ... } ⇒ Object
Overwrite devise to provide JSON responses as well.
Instance Method Details
#create {|resource| ... } ⇒ Object
Overwrite devise to provide JSON responses as well
4 5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/contour/sessions_controller.rb', line 4 def create self.resource = warden.authenticate!() (:notice, :signed_in) if is_flashing_format? sign_in(resource_name, resource) yield resource if block_given? respond_to do |format| format.html { respond_with resource, location: after_sign_in_path_for(resource) } format.json { render json: { success: true, resource_name => { id: resource.id, email: resource.email, first_name: resource.first_name, last_name: resource.last_name, authentication_token: (resource.respond_to?(:authentication_token) ? resource.authentication_token : nil) } } } end end |