def authenticate_lti_user(request, lti_user_id, lti_consumer):
 try:
  lti_user = LtiUser.objects.get(lti_user_id=lti_user_id, lti_consumer=lti_consumer)
 except LtiUser.DoesNotExist:
  lti_user = create_lti_user(lti_user_id, lti_consumer)
 if (not (request.user.is_authenticated() and (request.user == lti_user.edx_user))):
  switch_user(request, lti_user, lti_consumer)

def authenticate_lti_user ( request , lti_user_id , lti_consumer ) : try : lti_user = LtiUser . objects . get ( lti_user_id = lti_user_id , lti_consumer = lti_consumer ) except LtiUser . DoesNotExist : lti_user = create_lti_user ( lti_user_id , lti_consumer ) if ( not ( request . user . is_authenticated ( ) and ( request . user == lti_user . edx_user ) ) ) : switch_user ( request , lti_user , lti_consumer )
determine whether the user specified by the lti launch has an existing account .