diff --git a/lms/djangoapps/verify_student/views.py b/lms/djangoapps/verify_student/views.py index 704e7a3b67..b7ce48d626 100644 --- a/lms/djangoapps/verify_student/views.py +++ b/lms/djangoapps/verify_student/views.py @@ -837,6 +837,8 @@ class SubmitPhotosView(View): checkpoint (str): Location of the checkpoint in the course. """ + log.info((u"User {user_id} is submitting photos for ID verification").format(user_id=request.user.id)) + # If the user already has an initial verification attempt, we can re-use the photo ID # the user submitted with the initial attempt. initial_verification = SoftwareSecurePhotoVerification.get_initial_verification(request.user) @@ -848,7 +850,7 @@ class SubmitPhotosView(View): # If necessary, update the user's full name if "full_name" in params: - response = self._update_full_name(request.user, params["full_name"]) + response = self._update_full_name(request, params["full_name"]) if response is not None: return response @@ -856,7 +858,7 @@ class SubmitPhotosView(View): # Validation ensures that we'll have a face image, but we may not have # a photo ID image if this is a re-verification. face_image, photo_id_image, response = self._decode_image_data( - params["face_image"], params.get("photo_id_image") + request, params["face_image"], params.get("photo_id_image") ) # If we have a photo_id we do not want use the initial verification image. @@ -918,6 +920,7 @@ class SubmitPhotosView(View): # The face image is always required. if "face_image" not in params: msg = _("Missing required parameter face_image") + log.error((u"User {user_id} missing required parameter face_image").format(user_id=request.user.id)) return None, HttpResponseBadRequest(msg) # If provided, parse the course key and checkpoint location @@ -925,11 +928,12 @@ class SubmitPhotosView(View): try: params["course_key"] = CourseKey.from_string(params["course_key"]) except InvalidKeyError: + log.error((u"User {user_id} provided invalid course_key").format(user_id=request.user.id)) return None, HttpResponseBadRequest(_("Invalid course key")) return params, None - def _update_full_name(self, user, full_name): + def _update_full_name(self, request, full_name): """ Update the user's full name. @@ -942,16 +946,23 @@ class SubmitPhotosView(View): """ try: - update_account_settings(user, {"name": full_name}) + update_account_settings(request.user, {"name": full_name}) except UserNotFound: + log.error((u"No profile found for user {user_id}").format(user_id=request.user.id)) return HttpResponseBadRequest(_("No profile found for user")) except AccountValidationError: msg = _( u"Name must be at least {min_length} character long." ).format(min_length=NAME_MIN_LENGTH) + log.error( + (u"User {user_id} provided an account name less than {min_length} characters").format( + user_id=request.user.id, + min_length=NAME_MIN_LENGTH + ) + ) return HttpResponseBadRequest(msg) - def _decode_image_data(self, face_data, photo_id_data=None): + def _decode_image_data(self, request, face_data, photo_id_data=None): """ Decode image data sent with the request. @@ -979,6 +990,7 @@ class SubmitPhotosView(View): except InvalidImageData: msg = _("Image data is not valid.") + log.error((u"Image data for user {user_id} is not valid").format(user_id=request.user.id)) return None, None, HttpResponseBadRequest(msg) def _submit_attempt(self, user, face_image, photo_id_image=None, initial_verification=None):