Better auth errors under certain circumstances

pull/298/head
Rick Carlino 2016-11-18 14:54:39 -06:00
parent b7bdb042e9
commit bd4f1a0306
2 changed files with 2 additions and 3 deletions

View File

@ -35,8 +35,7 @@ private
def authenticate_user!
# All possible information that could be needed for any of the 3 auth
# strategies.
context = {
jwt: request.headers["Authorization"],
context = { jwt: request.headers["Authorization"],
user: current_user }
# Returns a symbol representing the appropriate auth strategy, or nil if
# unknown.

View File

@ -8,7 +8,7 @@ module Auth
token = SessionToken.decode!(just_the_token)
claims = token.unencoded
email = claims['sub']
User.find_by(email: email)
User.find_by!(email: email)
rescue JWT::DecodeError
add_error :jwt, :decode_error, "JSON Web Token is not valid."
end