Sha256: 875dcb68929920ab75748c4081e57fa19999014264a8bad0703903274f8cdfb9

Contents?: true

Size: 1.37 KB

Versions: 16

Compression:

Stored size: 1.37 KB

Contents

module Workarea
  module Api
    module Storefront
      class AuthenticationTokensController < Api::Storefront::ApplicationController
        before_action :ensure_not_locked, only: :create

        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

        def update
          @authentication_token = authenticate_with_http_token do |token, options|
            User::AuthenticationToken.refresh!(token, options)
          end

          if @authentication_token.blank?
            render(
              json: { problem: t('workarea.api.storefront.authentication_tokens.error') },
              status: :unprocessable_entity
            )
          end
        end

        private

        def ensure_not_locked
          if User.login_locked?(params[:email])
            render(
              json: {
                problem: t('workarea.api.storefront.authentication_tokens.login_locked')
              },
              status: :unprocessable_entity
            )

            return false
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
workarea-api-4.5.6 storefront/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-storefront-4.5.6 app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-4.5.5 storefront/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-storefront-4.5.5 app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-4.5.4 storefront/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-storefront-4.5.4 app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-4.5.3 storefront/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-storefront-4.5.3 app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-4.5.2 storefront/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-storefront-4.5.2 app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-4.5.0 storefront/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-storefront-4.5.0 app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-4.4.7 storefront/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-storefront-4.4.7 app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-4.4.6 storefront/app/controllers/workarea/api/storefront/authentication_tokens_controller.rb
workarea-api-storefront-4.4.6 app/controllers/workarea/api/storefront/authentication_tokens_controller.rb