Added Force-SSL switch to System Settings
This commit is contained in:
@@ -5,11 +5,11 @@
|
||||
<%@ Register tagPrefix="Swarmops5" tagName="AjaxTextBox" src="~/Controls/v5/Base/AjaxTextBox.ascx" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
|
||||
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#divTabs').tabs();
|
||||
|
||||
$('.EditCheck').switchbutton({
|
||||
checkedLabel: '<%= Global.Global_On.ToUpperInvariant() %>',
|
||||
uncheckedLabel: '<%= Global.Global_Off.ToUpperInvariant() %>',
|
||||
|
||||
@@ -1,15 +1,79 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="SystemSettings.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.SystemSettingsPage" %>
|
||||
<%@ Import Namespace="Resources" %>
|
||||
<%@ Register tagPrefix="Swarmops5" tagName="AjaxTextBox" src="~/Controls/v5/Base/AjaxTextBox.ascx" %>
|
||||
<%@ Register tagPrefix="Swarmops5" tagName="TreePositions" src="~/Controls/v5/Swarm/TreePositions.ascx" %>
|
||||
|
||||
<%@ Register tagPrefix="Swarmops5" tagName="DropDown" src="~/Controls/v5/Base/DropDown.ascx" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHead" Runat="Server">
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#divTabs').tabs();
|
||||
|
||||
setTimeout(function() {
|
||||
|
||||
$('.EditCheck').switchbutton({
|
||||
checkedLabel: '<%= Global.Global_On.ToUpperInvariant() %>',
|
||||
uncheckedLabel: '<%= Global.Global_Off.ToUpperInvariant() %>',
|
||||
}).change(function() {
|
||||
|
||||
if (suppressSwitchResponse) {
|
||||
return;
|
||||
}
|
||||
|
||||
var jsonData = {};
|
||||
jsonData.switchName = $(this).attr("rel");
|
||||
jsonData.switchValue = $(this).prop('checked');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Admin/SystemSettings.aspx/SwitchToggled",
|
||||
data: $.toJSON(jsonData),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function(msg) {
|
||||
if (msg.d.Success) {
|
||||
if (msg.d.DisplayMessage.length > 2) { // the 2 is rather arbitrary. Read as "if defined".
|
||||
alertify.log(msg.d.DisplayMessage);
|
||||
}
|
||||
} else {
|
||||
alertify.error(msg.d.DisplayMessage);
|
||||
}
|
||||
},
|
||||
error: function(msg) {
|
||||
// TODO: Reset switch, protest server unreachable
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Ask for initial data
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Pages/v5/Admin/SystemSettings.aspx/GetInitialData",
|
||||
data: "{}",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function(msg) {
|
||||
initializeSettings(msg.d);
|
||||
},
|
||||
error: function(msg) {
|
||||
// TODO: try again? bail out?
|
||||
alert("The server did not respond with the organization's current settings.");
|
||||
}
|
||||
|
||||
});
|
||||
}, 100); // delay the init of switchbuttons slightly to ensure visibility
|
||||
|
||||
});
|
||||
|
||||
function initializeSettings(systemSettings) {
|
||||
suppressSwitchResponse = true;
|
||||
$("#CheckRequireSsl").prop("checked", systemSettings.RequireSsl).change();
|
||||
suppressSwitchResponse = false;
|
||||
}
|
||||
|
||||
function onUrlChange(newText) {
|
||||
// Find domain and reset the admin sender name
|
||||
// TODO
|
||||
@@ -20,14 +84,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
var suppressSwitchResponse = false;
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<style type="text/css">
|
||||
.IconEdit { cursor: pointer; }
|
||||
|
||||
#IconCloseEdit { cursor: pointer; }
|
||||
|
||||
.CheckboxContainer {
|
||||
float: right;
|
||||
padding-top: 6px;
|
||||
padding-right: 8px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
</asp:Content>
|
||||
|
||||
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderMain" Runat="Server">
|
||||
<div id="divTabs" class="easyui-tabs" data-options="tabWidth:70,tabHeight:70">
|
||||
<div title="<img src='/Images/Icons/iconshock-switch-red-64px.png' />">
|
||||
<h2>System Behavior</h2>
|
||||
<div class="entryFields">
|
||||
<label for="CheckRequireSsl">SDAD</label><div class="CheckboxContainer"><input type="checkbox" rel="RequireSsl" class="EditCheck" id="CheckRequireSsl"/></div><br/>
|
||||
</div>
|
||||
<div class="entryLabels">
|
||||
Require SSL connection?<br/>
|
||||
</div>
|
||||
</div>
|
||||
<div title="<img src='/Images/Icons/iconshock-group-diversified-64px.png' />">
|
||||
<h2><asp:Label ID="LabelHeaderSysops" runat="server" /></h2>
|
||||
<Swarmops5:TreePositions ID="TreePositions" Level="SystemWide" runat="server" />
|
||||
|
||||
@@ -145,6 +145,54 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
this.LabelWebsocketPortClient.Text = Resources.Pages.Admin.SystemSettings_WebsocketPortClient;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static InitialSystemData GetInitialData()
|
||||
{
|
||||
InitialSystemData result = new InitialSystemData();
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
Organization org = authData.CurrentOrganization;
|
||||
|
||||
if (org == null || authData.CurrentUser == null)
|
||||
{
|
||||
return result; // just... don't
|
||||
}
|
||||
|
||||
result.RequireSsl = SystemSettings.RequireSsl;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
public static CallResult SwitchToggled(string switchName, bool switchValue)
|
||||
{
|
||||
AuthenticationData authData = GetAuthenticationDataAndCulture();
|
||||
|
||||
if (authData.CurrentOrganization == null || authData.CurrentUser == null)
|
||||
{
|
||||
return null; // just don't... don't anything, actually
|
||||
}
|
||||
|
||||
CallResult result = new CallResult();
|
||||
result.Success = true;
|
||||
result.DisplayMessage = string.Empty;
|
||||
|
||||
switch (switchName)
|
||||
{
|
||||
case "RequireSsl":
|
||||
|
||||
SystemSettings.RequireSsl = switchValue;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
[WebMethod]
|
||||
static public AjaxTextBox.CallbackResult StoreCallback(string newValue, string cookie)
|
||||
{
|
||||
@@ -282,6 +330,19 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class CallResult
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public string OpResult { get; set; }
|
||||
public string DisplayMessage { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class InitialSystemData
|
||||
{
|
||||
public bool RequireSsl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -409,8 +409,6 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
/// </summary>
|
||||
public static void InitDatabaseThread()
|
||||
{
|
||||
SwarmopsLog.DebugLog("Initializing Database");
|
||||
|
||||
// Ignore the session object, that method of sharing data didn't work, but a static variable did.
|
||||
|
||||
_initProgress = 1;
|
||||
@@ -443,8 +441,6 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
|
||||
Persistence.Key["SwarmopsInstallationId"] = Guid.NewGuid().ToString();
|
||||
|
||||
SwarmopsLog.DebugLog(" - creating currencies");
|
||||
|
||||
_initProgress = 4;
|
||||
_initMessage = "Initializing currencies...";
|
||||
|
||||
@@ -555,7 +551,6 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
{
|
||||
// Use initMessage to push info about what went wrong to the user
|
||||
|
||||
SwarmopsLog.DebugLog (failedException.ToString());
|
||||
_initMessage = failedException.ToString();
|
||||
}
|
||||
|
||||
@@ -694,8 +689,6 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
|
||||
try
|
||||
{
|
||||
SwarmopsLog.DebugLog (String.Format ("Creating first user: '{0}', '{1}', '{2}'", name, mail, password));
|
||||
|
||||
Person personOne = null;
|
||||
bool personOneExists = false;
|
||||
|
||||
@@ -729,18 +722,12 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
throw new InvalidOperationException ("Cannot run initialization processes again when initialized.");
|
||||
}
|
||||
|
||||
SwarmopsLog.DebugLog ("- person one did not exist, creating");
|
||||
|
||||
Person newPerson = Person.Create (name, mail, password, string.Empty, string.Empty, string.Empty,
|
||||
string.Empty, string.Empty, DateTime.MinValue, PersonGender.Unknown);
|
||||
|
||||
SwarmopsLog.DebugLog ("- adding participation in Sandbox");
|
||||
|
||||
newPerson.AddParticipation (Organization.Sandbox, DateTime.MaxValue);
|
||||
// Add membership in Sandbox
|
||||
|
||||
SwarmopsLog.DebugLog ("- creating positions");
|
||||
|
||||
// Initialize staffing to System and Sandbox with the new user
|
||||
|
||||
Positions.CreateSysadminPositions();
|
||||
@@ -748,7 +735,6 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SwarmopsLog.DebugLog (e.ToString());
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -757,8 +743,6 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
|
||||
protected void ButtonLogin_Click (object sender, EventArgs args)
|
||||
{
|
||||
SwarmopsLog.DebugLog("ButtonLogin_Click");
|
||||
|
||||
// Check the host names and addresses again as a security measure - after all, we can be called from outside our intended script
|
||||
|
||||
if (!(VerifyHostName (this.TextServerName.Text) && VerifyHostAddress (this.TextServerAddress.Text)))
|
||||
@@ -786,13 +770,9 @@ namespace Swarmops.Frontend.Pages.v5.Public
|
||||
|
||||
// Get authenticated person
|
||||
|
||||
SwarmopsLog.DebugLog (" - before calling Authenticate");
|
||||
|
||||
Person expectedPersonOne = Authentication.Authenticate ("1",
|
||||
this.TextFirstUserPassword1.Text);
|
||||
|
||||
SwarmopsLog.DebugLog(" - after calling Authenticate");
|
||||
|
||||
if (expectedPersonOne != null)
|
||||
{
|
||||
Authority firstAuthority = Authority.FromLogin(expectedPersonOne, Organization.Sandbox);
|
||||
|
||||
Reference in New Issue
Block a user