class Lockie::Strategies::Jwt

Public Instance Methods

auth() click to toggle source
# File lib/lockie/strategies/jwt.rb, line 7
def auth
  @auth ||= ActionDispatch::Request.new(env)
end
authenticate!() click to toggle source
# File lib/lockie/strategies/jwt.rb, line 23
def authenticate!
  begin
    auth = auth_object.find_by_token(token)
    if auth
      success! auth
    else
      set_message "Invalid token"
      fail!
    end
  rescue # => err
    set_message "Invalid token"
    fail!
  end
end
headers() click to toggle source
# File lib/lockie/strategies/jwt.rb, line 11
def headers
  auth.headers
end
token() click to toggle source
# File lib/lockie/strategies/jwt.rb, line 19
def token
  headers['Authorization'].split.last.strip
end
valid?() click to toggle source
# File lib/lockie/strategies/jwt.rb, line 15
def valid?
  headers['Authorization'].present?
end