Skip to content

Commit 7cbd4c9

Browse files
committed
check authentication at the start of download-or-update-course-exercises
1 parent 54bf64c commit 7cbd4c9

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tmc-client/src/tmc_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct TmcCore {
5656
// TODO: cache API results?
5757
impl TmcClient {
5858
/// Convenience function for checking authentication.
59-
fn require_authentication(&self) -> Result<(), ClientError> {
59+
pub fn require_authentication(&self) -> Result<(), ClientError> {
6060
if self.0.token.is_some() {
6161
Ok(())
6262
} else {

tmc-langs/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ pub fn paste_exercise(
208208
}
209209

210210
/// Downloads the given exercises, by either downloading the exercise template, updating the exercise or downloading an old submission.
211+
/// Requires authentication.
211212
/// If the exercise doesn't exist on disk yet...
212213
/// if there are previous submissions and download_template is not set, the latest submission is downloaded.
213214
/// otherwise, the exercise template is downloaded.
@@ -223,6 +224,8 @@ pub fn download_or_update_course_exercises(
223224
projects_dir.display()
224225
);
225226

227+
client.require_authentication()?;
228+
226229
let exercises_details = client.get_exercises_details(exercises)?;
227230
let projects_config = ProjectsConfig::load(projects_dir)?;
228231

0 commit comments

Comments
 (0)