Better auth errors under certain circumstances
parent
b7bdb042e9
commit
bd4f1a0306
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue