Files
Disco/Disco.Web/Areas/API/Controllers/BootstrapperController.cs
T
2025-07-20 11:59:28 +10:00

54 lines
1.7 KiB
C#

using Disco.Services.Authorization;
using Disco.Services.Web;
using System;
using System.Web.Mvc;
namespace Disco.Web.Areas.API.Controllers
{
[DiscoAuthorize(Claims.Config.Enrolment.Configure)]
public partial class BootstrapperController : AuthorizedDatabaseController
{
public virtual ActionResult MacSshUsername(string MacSshUsername)
{
try
{
if (!string.IsNullOrWhiteSpace(MacSshUsername))
{
Database.DiscoConfiguration.Bootstrapper.MacSshUsername = MacSshUsername;
Database.SaveChanges();
return Json("OK", JsonRequestBehavior.AllowGet);
}
else
{
throw new Exception("The Username cannot be null or empty");
}
}
catch (Exception ex)
{
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
public virtual ActionResult MacSshPassword(string MacSshPassword)
{
try
{
if (!string.IsNullOrWhiteSpace(MacSshPassword))
{
Database.DiscoConfiguration.Bootstrapper.MacSshPassword = MacSshPassword;
Database.SaveChanges();
return Json("OK", JsonRequestBehavior.AllowGet);
}
else
{
throw new Exception("The Password cannot be null or empty");
}
}
catch (Exception ex)
{
return Json($"Error: {ex.Message}", JsonRequestBehavior.AllowGet);
}
}
}
}