Esempio n. 1
0
        /// <summary>
        /// Checks to see if the current user is authorized to access the
        /// specified assessment.  Throws an HttpResponseException if not.
        /// </summary>
        /// <param name="assessmentId"></param>
        public static void AuthorizeUserForAssessment(int assessmentId)
        {
            AssessmentManager assessmentManager = new AssessmentManager();

            if (!assessmentManager.IsCurrentUserOnAssessment(assessmentId))
            {
                var resp = new HttpResponseMessage(HttpStatusCode.Unauthorized)
                {
                    Content      = new StringContent("User not authorized for assessment"),
                    ReasonPhrase = "The current user is not authorized to access the target assessment"
                };
                throw new HttpResponseException(resp);
            }
        }