Class: Lockie::Strategies::Jwt
- Inherits:
-
Warden::Strategies::Base
- Object
- Warden::Strategies::Base
- Lockie::Strategies::Jwt
- Includes:
- LogHelper, ModelHelper
- Defined in:
- lib/lockie/strategies/jwt.rb
Instance Method Summary collapse
Methods included from LogHelper
Methods included from ModelHelper
Instance Method Details
#auth ⇒ Object
7 8 9 |
# File 'lib/lockie/strategies/jwt.rb', line 7 def auth @auth ||= ActionDispatch::Request.new(env) end |
#authenticate! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lockie/strategies/jwt.rb', line 23 def authenticate! begin auth = auth_object.find_by_token(token) if auth success! auth else "Invalid token" fail! end rescue # => err "Invalid token" fail! end end |
#headers ⇒ Object
11 12 13 |
# File 'lib/lockie/strategies/jwt.rb', line 11 def headers auth.headers end |
#token ⇒ Object
19 20 21 |
# File 'lib/lockie/strategies/jwt.rb', line 19 def token headers['Authorization'].split.last.strip end |
#valid? ⇒ Boolean
15 16 17 |
# File 'lib/lockie/strategies/jwt.rb', line 15 def valid? headers['Authorization'].present? end |