app/controllers/application_controller.rb
# Check for auth headers - if present, decode or send unauthorized response (called always to allow current_user)
Check for auth headers - if present, decode or send unauthorized response (called always to allow current_user)
Check for auth headers - if present decode or send unauthorized response ( called always to allow current_user )
def process_token
          if request.headers['Authorization'].present?
            begin
              token = request.headers['Authorization'].split(' ')[1]
              jwt_payload = JWT.decode(token, nil, false)[0]
              @current_user_id = jwt_payload['id']
            rescue JWT::ExpiredSignature, JWT::VerificationError, JWT::DecodeError
            head :unauthorized
            end
          end
        end
def process_token if request . headers [ 'Authorization' ] . present? begin token = request . headers [ 'Authorization' ] . split ( ' ' ) [ 1 ] jwt_payload = JWT . decode ( token , nil , false ) [ 0 ] @current_user_id = jwt_payload [ 'id' ] rescue JWT :: ExpiredSignature , JWT :: VerificationError , JWT :: DecodeError head :unauthorized end end end
Check for auth headers - if present, decode or send unauthorized response (called always to allow current_user)
Check for auth headers - if present decode or send unauthorized response ( called always to allow current_user )
#jwt_payload = JWT.decode(request.headers['Authorization'].split(' ')[1], Rails.application.secrets.secret_key_base).first