Class: Authr::SessionsController
- Inherits:
-
Devise::SessionsController
- Object
- Devise::SessionsController
- Authr::SessionsController
- Defined in:
- app/controllers/authr/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/authr/sessions_controller.rb', line 3 def create respond_to do |format| format.html { super } format.json do if warden.authenticate() self.resource = warden.authenticate!() sign_in(resource_name, resource) data = { token: self.resource.authentication_token, email: self.resource.email } render json: data, status: 201 else render json: { error: :invalid }, status: 401 end end end end |