aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application/Management/API/Controllers/SessionController.cs
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-07-24 13:25:17 -0500
committerJP Dillingham <jpdillingham@gmail.com>2021-07-24 13:25:17 -0500
commitf210cb335277b17a18ca01591223adad53e60e2d (patch)
tree95bfd75f910a492839c4f520336e403570efd976 /src/slskd/Application/Management/API/Controllers/SessionController.cs
parent98c2f99198ecc48f8d4d0de1342a455a844e6c44 (diff)
downloadslskd-f210cb335277b17a18ca01591223adad53e60e2d.tar.gz
allow web un/pw to be changed at runtime
Diffstat (limited to 'src/slskd/Application/Management/API/Controllers/SessionController.cs')
-rw-r--r--src/slskd/Application/Management/API/Controllers/SessionController.cs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/slskd/Application/Management/API/Controllers/SessionController.cs b/src/slskd/Application/Management/API/Controllers/SessionController.cs
index 442970b9..02e8257e 100644
--- a/src/slskd/Application/Management/API/Controllers/SessionController.cs
+++ b/src/slskd/Application/Management/API/Controllers/SessionController.cs
@@ -15,6 +15,8 @@
// along with this program. If not, see https://www.gnu.org/licenses/.
// </copyright>
+using Microsoft.Extensions.Options;
+
namespace slskd.Management.API
{
using System;
@@ -37,14 +39,17 @@ namespace slskd.Management.API
public class SessionController : ControllerBase
{
public SessionController(
+ IOptionsSnapshot<Options> optionsSnapshot,
OptionsAtStartup optionsAtStartup,
SymmetricSecurityKey jwtSigningKey)
{
+ OptionsSnapshot = optionsSnapshot;
OptionsAtStartup = optionsAtStartup;
JwtSigningKey = jwtSigningKey;
}
private SymmetricSecurityKey JwtSigningKey { get; set; }
+ private IOptionsSnapshot<Options> OptionsSnapshot { get; set; }
private OptionsAtStartup OptionsAtStartup { get; set; }
/// <summary>
@@ -106,7 +111,7 @@ namespace slskd.Management.API
}
// only admin login for now
- if (OptionsAtStartup.Web.Authentication.Username == login.Username && OptionsAtStartup.Web.Authentication.Password == login.Password)
+ if (OptionsSnapshot.Value.Web.Authentication.Username == login.Username && OptionsSnapshot.Value.Web.Authentication.Password == login.Password)
{
return Ok(new TokenResponse(GetJwtSecurityToken(login.Username, Role.Administrator)));
}