Skip to content

Commit

Permalink
Merge pull request #1557 from pkuehnel/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pkuehnel authored Oct 14, 2024
2 parents 6dfc89d + 93d0dc5 commit 30f9386
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IIssueKeys
string FleetApiTokenRequestExpired { get; }
string FleetApiTokenNotReceived { get; }
string FleetApiTokenExpired { get; }
string FleetApiTokenRefreshNonSuccessStatusCode { get; }
string FleetApiTokenNoApiRequestsAllowed { get; }
string CrashedOnStartup { get; }
string RestartNeeded { get; }
Expand All @@ -19,7 +20,6 @@ public interface IIssueKeys
string FleetApiNonSuccessStatusCode { get; }
string FleetApiNonSuccessResult { get; }
string UnsignedCommand { get; }
string FleetApiTokenRefreshNonSuccessStatusCode { get; }
string CarRateLimited { get; }
string BleCommandNoSuccess { get; }
string SolarValuesNotAvailable { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class IssueKeys : IIssueKeys
public string FleetApiTokenMissingScopes => "FleetApiTokenMissingScopes";
public string FleetApiTokenRequestExpired => "FleetApiTokenRequestExpired";
public string FleetApiTokenNotReceived => "FleetApiTokenNotReceived";
public string FleetApiTokenRefreshNonSuccessStatusCode => "FleetApiTokenRefreshNonSuccessStatusCode";
public string FleetApiTokenExpired => "FleetApiTokenExpired";
public string FleetApiTokenNoApiRequestsAllowed => "FleetApiRequestsNotAllowed";
public string CrashedOnStartup => "CrashedOnStartup";
Expand All @@ -21,7 +22,6 @@ public class IssueKeys : IIssueKeys
public string FleetApiNonSuccessStatusCode => "FleetApiNonSuccessStatusCode_";
public string FleetApiNonSuccessResult => "FleetApiNonSuccessResult_";
public string UnsignedCommand => "UnsignedCommand";
public string FleetApiTokenRefreshNonSuccessStatusCode => "FleetApiTokenRefreshNonSuccessStatusCode";
public string CarRateLimited => "CarRateLimited";
public string BleCommandNoSuccess => "BleCommandNoSuccess_";
public string SolarValuesNotAvailable => "SolarValuesNotAvailable";
Expand Down
10 changes: 8 additions & 2 deletions TeslaSolarCharger/Server/Services/BackendApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public async Task<DtoValue<string>> StartTeslaOAuth(string locale, string baseUr
logger.LogTrace("{method}()", nameof(StartTeslaOAuth));
var currentTokens = await teslaSolarChargerContext.TeslaTokens.ToListAsync().ConfigureAwait(false);
teslaSolarChargerContext.TeslaTokens.RemoveRange(currentTokens);
var cconfigEntriesToRemove = await teslaSolarChargerContext.TscConfigurations
var configEntriesToRemove = await teslaSolarChargerContext.TscConfigurations
.Where(c => c.Key == constants.TokenMissingScopes)
.ToListAsync().ConfigureAwait(false);
teslaSolarChargerContext.TscConfigurations.RemoveRange(cconfigEntriesToRemove);
teslaSolarChargerContext.TscConfigurations.RemoveRange(configEntriesToRemove);
await teslaSolarChargerContext.SaveChangesAsync().ConfigureAwait(false);
var installationId = await tscConfigurationService.GetInstallationId().ConfigureAwait(false);
var backendApiBaseUrl = configurationWrapper.BackendApiBaseUrl();
Expand Down Expand Up @@ -63,7 +63,13 @@ public async Task<DtoValue<string>> StartTeslaOAuth(string locale, string baseUr
await errorHandlingService.HandleError(nameof(BackendApiService), nameof(StartTeslaOAuth), "Waiting for Tesla token",
"Waiting for the Tesla Token from the TSC backend. This might take up to five minutes. If after five minutes this error is still displayed, open the <a href=\"/BaseConfiguration\">Base Configuration</a> and request a new token.",
issueKeys.FleetApiTokenNotReceived, null, null);
//Do not set FleetApiTokenNotReceived to resolved here, as the token might still be in transit
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenNotRequested, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenUnauthorized, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenMissingScopes, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenRequestExpired, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenExpired, null);
await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenRefreshNonSuccessStatusCode, null);
return new DtoValue<string>(requestUrl);
}

Expand Down

0 comments on commit 30f9386

Please sign in to comment.