From 6e85dd6e944039943e9c2ce4ffd5cf960a0acf51 Mon Sep 17 00:00:00 2001
From: Dan <daniel2.lorych@live.uwe.ac.uk>
Date: Sat, 30 Apr 2022 10:00:35 +0100
Subject: [PATCH] Fix Login query and SQL connection

---
 Helios/Source/LoginService.cs | 4 ++++
 Helios/appsettings.json       | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/Helios/Source/LoginService.cs b/Helios/Source/LoginService.cs
index 3cc92a5..c07b5c6 100644
--- a/Helios/Source/LoginService.cs
+++ b/Helios/Source/LoginService.cs
@@ -27,6 +27,8 @@ namespace Helios.Source
 
         private Login GetUserDetails(Login userLogin)
         {
+            _connection.Open();
+
             NpgsqlCommand cmd = new NpgsqlCommand("select * from user_login where email = @emailParam and user_password = @passwordParam", _connection);
 
             cmd.Parameters.AddWithValue("@emailParam", userLogin.EmailAddress);
@@ -45,6 +47,8 @@ namespace Helios.Source
                 userLogin.IsAdmin = false;
             }
 
+            _connection.Close();
+
             return userLogin;
         }
     }
diff --git a/Helios/appsettings.json b/Helios/appsettings.json
index aa0ca7c..3a0bc9a 100644
--- a/Helios/appsettings.json
+++ b/Helios/appsettings.json
@@ -1,6 +1,6 @@
 {
   "ConnectionStrings": {
-    "Default": "User ID=myusername;Password=mypassword;Host=localhost;Port=5432;Database=helios;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;"
+    "Default": "User ID=myusername;Password=mypassword;Host=localhost;Port=5432;Database=helios;"
   },
   "Logging": {
     "LogLevel": {
-- 
GitLab