Module: Cabal::API::Common::Authenticated
- Included in:
- V3::List
- Defined in:
- lib/cabal/api/common/authenticated.rb
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cabal/api/common/authenticated.rb', line 7 def self.included(base) base.class_eval do helpers do def current_user = headers['Authorization'].to_s access_key, signature = .split(':') user = Cabal::API::User.find(access_key: access_key).first if user && user.authenticated_with?(signature) user else nil end end def authenticate! error!({message: 'Unauthorized.'}, 401) unless current_user end end end end |