Class: Workarea::Api::Storefront::AuthenticationTokensController
- Inherits:
-
ApplicationController
- Object
- Workarea::ApplicationController
- ApplicationController
- Workarea::Api::Storefront::AuthenticationTokensController
- Defined in:
- app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
#assert_current_metrics_id, #cache_page, #skip_session
Methods included from Authentication
#authentication?, #current_user, find_user
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/workarea/api/storefront/authentication_tokens_controller.rb', line 7 def create user = User.find_for_login(params[:email], params[:password]) if user.blank? render( json: { problem: t('workarea.api.storefront.authentication_tokens.error') }, status: :unprocessable_entity ) else @authentication_token = User::AuthenticationToken.create!(user: user) end end |
#update ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/workarea/api/storefront/authentication_tokens_controller.rb', line 20 def update @authentication_token = authenticate_with_http_token do |token, | User::AuthenticationToken.refresh!(token, ) end if @authentication_token.blank? render( json: { problem: t('workarea.api.storefront.authentication_tokens.error') }, status: :unprocessable_entity ) end end |