From c23149c5cc784793dd945b67e14fda231f32baf9 Mon Sep 17 00:00:00 2001 From: Kim Date: Thu, 20 Jul 2023 13:57:12 +0200 Subject: [PATCH] fixed some small bugs uncovered by testing --- csharp/App/Backend/Controller.cs | 2 +- csharp/App/Backend/DataTypes/Methods/ExoCmd.cs | 3 +-- csharp/App/Backend/DataTypes/Methods/Installation.cs | 3 ++- csharp/App/Backend/Database/Db.cs | 4 ++-- typescript/Frontend/src/config/axiosConfig.tsx | 5 +++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/csharp/App/Backend/Controller.cs b/csharp/App/Backend/Controller.cs index 74b45cb9a..12ffa12e9 100644 --- a/csharp/App/Backend/Controller.cs +++ b/csharp/App/Backend/Controller.cs @@ -317,7 +317,7 @@ public class Controller : ControllerBase var session = Db.GetSession(authToken); // TODO: automatic BadRequest when properties are null during deserialization - var installation = Db.GetFolderById(installationAccess.InstallationId); + var installation = Db.GetInstallationById(installationAccess.InstallationId); var user = Db.GetUserById(installationAccess.UserId); return session.GrantUserAccessTo(user, installation) diff --git a/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs b/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs index 97c77ac60..f4569d54b 100644 --- a/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs +++ b/csharp/App/Backend/DataTypes/Methods/ExoCmd.cs @@ -52,14 +52,13 @@ public static class ExoCmd //return $"{key};{secret}"; } - public static async void RevokeReadKey(this Installation installation) + public static async Task RevokeReadKey(this Installation installation) { try { await Exo .WithArguments("iam access-key revoke " + installation.S3Key + " -f " + " -C " + ConfigFile) .ExecuteAsync(); - } catch { diff --git a/csharp/App/Backend/DataTypes/Methods/Installation.cs b/csharp/App/Backend/DataTypes/Methods/Installation.cs index 62ba3453a..f20a7b325 100644 --- a/csharp/App/Backend/DataTypes/Methods/Installation.cs +++ b/csharp/App/Backend/DataTypes/Methods/Installation.cs @@ -16,7 +16,8 @@ public static class InstallationMethods public static async Task RenewS3Credentials(this Installation installation) { - installation.RevokeReadKey(); + if(installation.S3Key != "") await installation.RevokeReadKey(); + var (key, secret) = await installation.CreateReadKey(); if (installation.S3WriteKey == "" || installation.S3WriteSecret == "") diff --git a/csharp/App/Backend/Database/Db.cs b/csharp/App/Backend/Database/Db.cs index a3918d2cb..95b3e4aa7 100644 --- a/csharp/App/Backend/Database/Db.cs +++ b/csharp/App/Backend/Database/Db.cs @@ -18,7 +18,7 @@ namespace InnovEnergy.App.Backend.Database; public static partial class Db { - internal const String DbPath = "./db.sqlite"; + // internal const String DbPath = "./db.sqlite"; private static SQLiteConnection Connection { get; } = ((Func)(() => { @@ -169,7 +169,7 @@ public static partial class Db private static void DeleteStaleSessions() { - var deadline = DateTime.Now - Session.MaxAge; + var deadline = DateTime.Now.AddDays((-1)*Session.MaxAge.Days); Sessions.Delete(s => s.LastSeen < deadline); } diff --git a/typescript/Frontend/src/config/axiosConfig.tsx b/typescript/Frontend/src/config/axiosConfig.tsx index 75b3924a1..95616e2e0 100644 --- a/typescript/Frontend/src/config/axiosConfig.tsx +++ b/typescript/Frontend/src/config/axiosConfig.tsx @@ -1,12 +1,13 @@ import axios from "axios"; export const axiosConfigWithoutToken = axios.create({ - baseURL: "https://localhost:7087/api", + baseURL: "https://monitor.innov.energy/api", }); const axiosConfig = axios.create({ - baseURL: "https://localhost:7087/api", + baseURL: "https://monitor.innov.energy/api", }); + axiosConfig.defaults.params = {}; axiosConfig.interceptors.request.use( (config) => {