Added authorization check with handling for security error and user role detected other than a teacher