Moved the ugly old login; making room for new one

This commit is contained in:
Rick Falkvinge
2014-10-29 11:56:45 +01:00
parent 34ae177906
commit b3c9a7a417
3 changed files with 153 additions and 153 deletions
+1 -1
View File
@@ -5,4 +5,4 @@
# Update the LOC count on every sprint deploy.
find . \( -name '*.cs' -o -name '*.as?x' \) | xargs wc -l > LINESOFCODE
find . \( -name '*.cs' -o -name '*.as?x' \) | grep -v "External Dep" | xargs wc -l > LINESOFCODE
@@ -1,53 +1,53 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" EnableViewState="true" Inherits="Swarmops.Pages.Security.Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href='https://fonts.googleapis.com/css?family=Permanent+Marker' rel='stylesheet' type='text/css' />
<link href='https://fonts.googleapis.com/css?family=Arimo:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
<link href="../Style/style-v5.css" rel="stylesheet" type="text/css" />
<title>Swarmops Alpha - Login</title>
</head>
<body class="loginpage">
<div class="center640px">
<div style="height:100px">&nbsp;</div>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<script type="text/javascript">
//Put your JavaScript code here.
</script>
<div class="loginbox">
<div class="content">
<div class="content">
<div style="width:64px;height:64px;float:left"><img src="/Security/Images/iconshock-fingerprint-scanner-unlock-64px.png" alt="unlock icon" /></div><h1>PIRATEWEB5<span class="loginalphabetasign">&beta;</span> LOGIN</h1>
<div class="box">
<div class="content">
<div class="entryLabelsAdmin">
Login:<br />
Password:<br />
</div>
<div class="entryFieldsAdmin">
<asp:TextBox ID="TextLogin" runat="server" CssClass="textinput" />&nbsp;<br />
<asp:TextBox ID="TextPassword" runat="server" CssClass="textinput" TextMode="Password" />&nbsp;<br />
<div class="button-orange-encaps" style="float:right; margin-top:5px; margin-right:2px;margin-bottom:3px;">
<asp:Button ID="ButtonLogin" runat="server"
Text="Login" onclick="ButtonLogin_Click" CssClass="button button-orange" /></div><br clear="all" />
</div>
<div class="entryValidationAdmin">
<asp:RequiredFieldValidator ID="ValidatorRequired_Login" Text="Please enter a valid login." runat="server" Display="Dynamic" EnableClientScript="false" ControlToValidate="TextLogin" CssClass="" />&nbsp;<asp:Label ID="LabelLoginFailed" runat="server" Visible="false" Text="Login failed, please retry." /><br />
<asp:RequiredFieldValidator ID="ValidatorRequired_Password" Text="Please enter your password." runat="server" Display="Dynamic" EnableClientScript="false" ControlToValidate="TextPassword" CssClass="" />&nbsp;<br />
</div>
<div class="break"></div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login-Old.aspx.cs" EnableViewState="true" Inherits="Swarmops.Pages.Security.LoginOld" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href='https://fonts.googleapis.com/css?family=Permanent+Marker' rel='stylesheet' type='text/css' />
<link href='https://fonts.googleapis.com/css?family=Arimo:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css' />
<link href="../Style/style-v5.css" rel="stylesheet" type="text/css" />
<title>Swarmops Alpha - Login</title>
</head>
<body class="loginpage">
<div class="center640px">
<div style="height:100px">&nbsp;</div>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<script type="text/javascript">
//Put your JavaScript code here.
</script>
<div class="loginbox">
<div class="content">
<div class="content">
<div style="width:64px;height:64px;float:left"><img src="/Security/Images/iconshock-fingerprint-scanner-unlock-64px.png" alt="unlock icon" /></div><h1>PIRATEWEB5<span class="loginalphabetasign">&beta;</span> LOGIN</h1>
<div class="box">
<div class="content">
<div class="entryLabelsAdmin">
Login:<br />
Password:<br />
</div>
<div class="entryFieldsAdmin">
<asp:TextBox ID="TextLogin" runat="server" CssClass="textinput" />&nbsp;<br />
<asp:TextBox ID="TextPassword" runat="server" CssClass="textinput" TextMode="Password" />&nbsp;<br />
<div class="button-orange-encaps" style="float:right; margin-top:5px; margin-right:2px;margin-bottom:3px;">
<asp:Button ID="ButtonLogin" runat="server"
Text="Login" onclick="ButtonLogin_Click" CssClass="button button-orange" /></div><br clear="all" />
</div>
<div class="entryValidationAdmin">
<asp:RequiredFieldValidator ID="ValidatorRequired_Login" Text="Please enter a valid login." runat="server" Display="Dynamic" EnableClientScript="false" ControlToValidate="TextLogin" CssClass="" />&nbsp;<asp:Label ID="LabelLoginFailed" runat="server" Visible="false" Text="Login failed, please retry." /><br />
<asp:RequiredFieldValidator ID="ValidatorRequired_Password" Text="Please enter your password." runat="server" Display="Dynamic" EnableClientScript="false" ControlToValidate="TextPassword" CssClass="" />&nbsp;<br />
</div>
<div class="break"></div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</body>
</html>
@@ -1,99 +1,99 @@
using System;
using System.Threading;
using System.Web;
using System.Web.Security;
using Swarmops.Basic.Types;
using Swarmops.Database;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
namespace Swarmops.Pages.Security
{
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Check if this is the first run ever. If so, redirect to Init.
if (!SwarmDb.Configuration.IsConfigured())
{
Response.Redirect("/Pages/v5/Init/", true);
return;
}
// If this is the Dev Sandbox, autologin
if (Request.Url.Host == "dev.swarmops.com" &&
PilotInstallationIds.IsPilot(PilotInstallationIds.DevelopmentSandbox))
{
Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode("<p>You have been logged on as <strong>Sandbox Administrator</strong> to the Swarmops Development Sandbox.</p><br/><p>This machine runs the latest development build, so you may run into diagnostic code and half-finished features. All data here is bogus test data and is reset every night.</p><br/><p><strong>In other words, welcome, and play away!</strong></p><br/><br/>")));
FormsAuthentication.RedirectFromLoginPage("1,1", true);
}
// THE DAMN BITID NEEDS TO GO INTO ANDROID WALLET SO WE CAN STREAMLINE AND REWRITE THIS POS
this.LabelLoginFailed.Visible = false;
this.TextLogin.Focus();
// Check for SSL and force it
// Special case for CloudFlare deployments - there is a case where somebody will get their connections de-SSLed at the server
string cloudFlareVisitorScheme = Request.Headers["CF-Visitor"];
bool cloudFlareSsl = false;
if (!string.IsNullOrEmpty(cloudFlareVisitorScheme))
{
if (cloudFlareVisitorScheme.Contains("\"scheme\":\"https\""))
{
cloudFlareSsl = true;
}
}
// TODO: Same thing for Pound deployments
// Rewrite if applicable
if (Request.Url.ToString().StartsWith("http://") && !cloudFlareSsl) // only check client-side as many server sites de-SSL the connection before reaching the web server
{
if (!Request.Url.ToString().StartsWith("http://dev.swarmops.com/") && !Request.Url.ToString().StartsWith("http://localhost:") && !Request.Url.ToString().StartsWith("http://swarmops-"))
{
Response.Redirect(Request.Url.ToString().Replace("http:", "https:"));
}
}
}
protected void ButtonLogin_Click(object sender, EventArgs e)
{
string loginToken = this.TextLogin.Text;
string password = this.TextPassword.Text;
if (!string.IsNullOrEmpty(loginToken.Trim()) && !string.IsNullOrEmpty(password.Trim()))
{
try
{
BasicPerson authenticatedPerson = Swarmops.Logic.Security.Authentication.Authenticate(loginToken, password);
Person p = Person.FromIdentity(authenticatedPerson.PersonId);
if (p.PreferredCulture != Thread.CurrentThread.CurrentCulture.Name)
p.PreferredCulture = Thread.CurrentThread.CurrentCulture.Name;
// TODO: Determine logged-on organization; possibly ask for clarification
FormsAuthentication.RedirectFromLoginPage(authenticatedPerson.PersonId.ToString() + ",1", true);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.ToString());
this.LabelLoginFailed.Text = exception.ToString();
this.LabelLoginFailed.Visible = true;
this.TextLogin.Focus();
}
}
}
}
}
using System;
using System.Threading;
using System.Web;
using System.Web.Security;
using Swarmops.Basic.Types;
using Swarmops.Database;
using Swarmops.Logic.Support;
using Swarmops.Logic.Swarm;
namespace Swarmops.Pages.Security
{
public partial class LoginOld : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Check if this is the first run ever. If so, redirect to Init.
if (!SwarmDb.Configuration.IsConfigured())
{
Response.Redirect("/Pages/v5/Init/", true);
return;
}
// If this is the Dev Sandbox, autologin
if (Request.Url.Host == "dev.swarmops.com" &&
PilotInstallationIds.IsPilot(PilotInstallationIds.DevelopmentSandbox))
{
Response.AppendCookie(new HttpCookie("DashboardMessage", HttpUtility.UrlEncode("<p>You have been logged on as <strong>Sandbox Administrator</strong> to the Swarmops Development Sandbox.</p><br/><p>This machine runs the latest development build, so you may run into diagnostic code and half-finished features. All data here is bogus test data and is reset every night.</p><br/><p><strong>In other words, welcome, and play away!</strong></p><br/><br/>")));
FormsAuthentication.RedirectFromLoginPage("1,1", true);
}
// THE DAMN BITID NEEDS TO GO INTO ANDROID WALLET SO WE CAN STREAMLINE AND REWRITE THIS POS
this.LabelLoginFailed.Visible = false;
this.TextLogin.Focus();
// Check for SSL and force it
// Special case for CloudFlare deployments - there is a case where somebody will get their connections de-SSLed at the server
string cloudFlareVisitorScheme = Request.Headers["CF-Visitor"];
bool cloudFlareSsl = false;
if (!string.IsNullOrEmpty(cloudFlareVisitorScheme))
{
if (cloudFlareVisitorScheme.Contains("\"scheme\":\"https\""))
{
cloudFlareSsl = true;
}
}
// TODO: Same thing for Pound deployments
// Rewrite if applicable
if (Request.Url.ToString().StartsWith("http://") && !cloudFlareSsl) // only check client-side as many server sites de-SSL the connection before reaching the web server
{
if (!Request.Url.ToString().StartsWith("http://dev.swarmops.com/") && !Request.Url.ToString().StartsWith("http://localhost:") && !Request.Url.ToString().StartsWith("http://swarmops-"))
{
Response.Redirect(Request.Url.ToString().Replace("http:", "https:"));
}
}
}
protected void ButtonLogin_Click(object sender, EventArgs e)
{
string loginToken = this.TextLogin.Text;
string password = this.TextPassword.Text;
if (!string.IsNullOrEmpty(loginToken.Trim()) && !string.IsNullOrEmpty(password.Trim()))
{
try
{
BasicPerson authenticatedPerson = Swarmops.Logic.Security.Authentication.Authenticate(loginToken, password);
Person p = Person.FromIdentity(authenticatedPerson.PersonId);
if (p.PreferredCulture != Thread.CurrentThread.CurrentCulture.Name)
p.PreferredCulture = Thread.CurrentThread.CurrentCulture.Name;
// TODO: Determine logged-on organization; possibly ask for clarification
FormsAuthentication.RedirectFromLoginPage(authenticatedPerson.PersonId.ToString() + ",1", true);
}
catch (Exception exception)
{
System.Diagnostics.Debug.WriteLine(exception.ToString());
this.LabelLoginFailed.Text = exception.ToString();
this.LabelLoginFailed.Visible = true;
this.TextLogin.Focus();
}
}
}
}
}