From 3604dc698411e26909e250ea33fb1b64cfe53a9c Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 25 Sep 2020 06:42:44 +1000 Subject: [PATCH] Add notification to advise users when the client needs to be reauthenticated (#1046) * Utilise errorAndNotify function to advise users when the client needs to be reauthenticated --- src/onedrive.d | 3 +++ src/sync.d | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/onedrive.d b/src/onedrive.d index 505cec39..29d22e69 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -726,6 +726,9 @@ final class OneDriveApi } } catch (OneDriveException e) { if (e.httpStatusCode == 400 || e.httpStatusCode == 401) { + // flag error and notify + log.errorAndNotify("\nERROR: Refresh token invalid, use --logout to authorize the client again.\n"); + // set error message e.msg ~= "\nRefresh token invalid, use --logout to authorize the client again"; } } diff --git a/src/sync.d b/src/sync.d index 91f252fe..82d0594e 100644 --- a/src/sync.d +++ b/src/sync.d @@ -305,7 +305,7 @@ final class SyncEngine if (e.httpStatusCode == 401) { // HTTP request returned status code 401 (Unauthorized) displayOneDriveErrorMessage(e.msg); - log.error("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n"); + log.errorAndNotify("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n"); // Must exit here exit(-1); } @@ -344,7 +344,7 @@ final class SyncEngine if (e.httpStatusCode == 401) { // HTTP request returned status code 401 (Unauthorized) displayOneDriveErrorMessage(e.msg); - log.error("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n"); + log.errorAndNotify("\nERROR: Check your configuration as your refresh_token may be empty or invalid. You may need to issue a --logout and re-authorise this client.\n"); // Must exit here exit(-1); }