Module: Workarea::Api::Storefront::Authentication
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- app/controllers/workarea/api/storefront/authentication.rb
Defined Under Namespace
Classes: InvalidError
Instance Method Summary collapse
Instance Method Details
#authentication? ⇒ Boolean
23 24 25 26 |
# File 'app/controllers/workarea/api/storefront/authentication.rb', line 23 def authentication? regex = ActionController::HttpAuthentication::Token::TOKEN_REGEX request..to_s[regex].present? end |
#current_user ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/controllers/workarea/api/storefront/authentication.rb', line 13 def current_user return @current_user if defined?(@current_user) user = authenticate_with_http_token do |token, | User::AuthenticationToken.authenticate(token, ).try(:user) end @current_user = user || raise(InvalidError) end |