diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index d3d98675..f007f443 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -120,12 +120,16 @@ class ExercisesController < ApplicationController end def import_uuid_check + user = user_for_oauth2_request + return render json: {}, status: 401 if user.nil? + uuid = params[:uuid] exercise = Exercise.find_by(uuid: uuid) return render json: {exercise_found: false, message: t('exercises.import_codeharbor.check.no_exercise')} if exercise.nil? + return render json: {exercise_found: true, update_right: false, message: t('exercises.import_codeharbor.check.exercise_found_no_right')} unless ExercisePolicy.new(user, exercise).update? - render json: {exercise_found: true, message: t('exercises.import_codeharbor.check.exercise_found')} + render json: {exercise_found: true, update_right: true, message: t('exercises.import_codeharbor.check.exercise_found')} end def import_proforma_xml diff --git a/config/locales/en.yml b/config/locales/en.yml index 8f32054a..f67c6c43 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -320,7 +320,8 @@ en: import_codeharbor: check: no_exercise: No corresponding exercise found on Codeocean. Pushing this exercise will create a new one on Codeocean, which will be linked to this one on Codeharbor, any changes to either one can be pushed to the respective other platform. - exercise_found: A corresponding exercise has been found on Codeocean. You can either