diff --git a/GECO/Account/Password.aspx b/GECO/Account/Password.aspx index 9ad52e73..ccd5d119 100644 --- a/GECO/Account/Password.aspx +++ b/GECO/Account/Password.aspx @@ -40,7 +40,7 @@   + ErrorMessage="Old Password is required." Font-Size="Small" ValidationGroup="OldPassword" ForeColor="Red">  @@ -50,11 +50,14 @@ + ErrorMessage="New Password is required." Font-Size="Small" ValidationGroup="NewPassword" ForeColor="Red"> + @@ -65,17 +68,245 @@ + ErrorMessage="Password Confirmation is required." Font-Size="Small" ValidationGroup="RepeatPassword" ForeColor="Red">   + ErrorMessage="Password fields must match." Font-Size="Small" Display="Dynamic" ValidationGroup="RepeatPassword" ForeColor="Red"> 

- +

-

NOTE: New password must contain at least 8 characters with at least 1 uppercase letter, 1 lowercase letter and 1 number.

+

NOTE: New password must have at least 12 characters, cannot include your login, and is not in a list of passwords commonly used on other websites.

+ + diff --git a/GECO/Account/Password.aspx.designer.vb b/GECO/Account/Password.aspx.designer.vb index 06e85d33..91d07db6 100644 --- a/GECO/Account/Password.aspx.designer.vb +++ b/GECO/Account/Password.aspx.designer.vb @@ -121,6 +121,15 @@ Partial Public Class Account_Password ''' Protected WithEvents Regex3 As Global.System.Web.UI.WebControls.RegularExpressionValidator + ''' + '''passwordRequirements control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents passwordRequirements As Global.System.Web.UI.WebControls.CustomValidator + ''' '''txtPwdConfirm control. ''' diff --git a/GECO/Account/Password.aspx.vb b/GECO/Account/Password.aspx.vb index e5752ded..8da61456 100644 --- a/GECO/Account/Password.aspx.vb +++ b/GECO/Account/Password.aspx.vb @@ -49,4 +49,74 @@ Partial Class Account_Password End If End Sub + Protected Sub passwordRequirement_ServerValidate(source As Object, args As ServerValidateEventArgs) Handles passwordRequirements.ServerValidate + If checkPasswordValid() Then + passwordRequirements.ErrorMessage = "The password cannot contain segments of the URL, app name, or email." + args.IsValid = False + End If + End Sub + + ''' + ''' Helper function for the passwordRequirement_ServerValidate() + ''' + ''' True if the password Is valid, false otherwise. + Private Function checkPasswordValid() As Boolean + Dim email As String = lblDisplayName.Text.ToLower + Dim password As String = txtNewPassword.Text.ToLower + + ' check if these passwords matches the email Or website + Dim validPassEmail As Integer = FindIntersection(email, password) + Dim validPassWebsite As Integer = FindIntersection("geco", password) + Dim validPassDepartment As Integer = FindIntersection("gaepd", password) + + ' declare an arbitrary length + Dim maxSequenceLength As Integer = 3 + Return validPassEmail <= maxSequenceLength AndAlso + validPassWebsite <= maxSequenceLength AndAlso + validPassDepartment <= maxSequenceLength + End Function + + ''' + ''' Find where the sequence starts And its length between 2 strings + ''' + ''' First string + ''' Second string + ''' 0 if there are no sequence, else return the length + Private Function FindIntersection(a As String, b As String) As Integer + Dim bestResult As Integer = 0 + For i As Integer = 0 To a.Length - 2 + Dim result As Integer = FindIntersectionFromStart(a.Substring(i), b) + If result <> 0 Then + If bestResult = 0 Then + bestResult = result + Else + If result > bestResult Then + bestResult = result + End If + End If + End If + If bestResult >= a.Length - i Then + Exit For + End If + Next + Return bestResult + End Function + + ''' + ''' Helper method for FindIntersection() + ''' + ''' First string + ''' Second string + ''' 0 if there are no sequence, else return the length + Private Function FindIntersectionFromStart(a As String, b As String) As Integer + For i As Integer = a.Length To 1 Step -1 + Dim d As String = a.Substring(0, i) + Dim j As Integer = b.IndexOf(d) + If j >= 0 Then + Return i ' return the length + End If + Next + Return 0 + End Function + End Class diff --git a/GECO/Register.aspx b/GECO/Register.aspx index 8a42e742..62a224cd 100644 --- a/GECO/Register.aspx +++ b/GECO/Register.aspx @@ -13,36 +13,38 @@
- - + - + ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ForeColor="red" /> +


- - + +
- Password must contain at least 8 characters with at least 1 uppercase letter, 1 lowercase letter and 1 number. + Password needs to have at least 12 characters, cannot include your login, and is not in a list of passwords commonly used on other websites.


- - + +

@@ -51,10 +53,10 @@
- - + +

- +

@@ -85,4 +88,234 @@ + diff --git a/GECO/Register.aspx.designer.vb b/GECO/Register.aspx.designer.vb index 84e25fa2..18e6237e 100644 --- a/GECO/Register.aspx.designer.vb +++ b/GECO/Register.aspx.designer.vb @@ -12,7 +12,7 @@ Option Explicit On Partial Public Class Register - + '''

'''lblEmail control. ''' @@ -21,7 +21,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblEmail As Global.System.Web.UI.WebControls.Label - + ''' '''txtEmail control. ''' @@ -30,7 +30,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtEmail As Global.System.Web.UI.WebControls.TextBox - + ''' '''RequiredFieldValidator6 control. ''' @@ -39,7 +39,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents RequiredFieldValidator6 As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''RegularExpressionValidator1 control. ''' @@ -48,7 +48,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents RegularExpressionValidator1 As Global.System.Web.UI.WebControls.RegularExpressionValidator - + ''' '''cvEmailExists control. ''' @@ -57,7 +57,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cvEmailExists As Global.System.Web.UI.WebControls.CustomValidator - + ''' '''lblPwd control. ''' @@ -66,7 +66,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblPwd As Global.System.Web.UI.WebControls.Label - + ''' '''txtPwd control. ''' @@ -75,7 +75,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtPwd As Global.System.Web.UI.WebControls.TextBox - + ''' '''RequiredFieldValidator15 control. ''' @@ -84,7 +84,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents RequiredFieldValidator15 As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''Regex3 control. ''' @@ -93,7 +93,16 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents Regex3 As Global.System.Web.UI.WebControls.RegularExpressionValidator - + + ''' + '''passwordRequirements control. + ''' + ''' + '''Auto-generated field. + '''To modify move field declaration from designer file to code-behind file. + ''' + Protected WithEvents passwordRequirements As Global.System.Web.UI.WebControls.CustomValidator + ''' '''lblPwdConfirm control. ''' @@ -102,7 +111,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblPwdConfirm As Global.System.Web.UI.WebControls.Label - + ''' '''txtPwdConfirm control. ''' @@ -111,7 +120,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtPwdConfirm As Global.System.Web.UI.WebControls.TextBox - + ''' '''RequiredFieldValidator16 control. ''' @@ -120,7 +129,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents RequiredFieldValidator16 As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''CompareValidator1 control. ''' @@ -129,7 +138,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents CompareValidator1 As Global.System.Web.UI.WebControls.CompareValidator - + ''' '''CaptchaUpdatePanel control. ''' @@ -138,7 +147,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents CaptchaUpdatePanel As Global.System.Web.UI.UpdatePanel - + ''' '''lblCaptcha control. ''' @@ -147,7 +156,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lblCaptcha As Global.System.Web.UI.WebControls.Label - + ''' '''txtCaptcha control. ''' @@ -156,7 +165,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents txtCaptcha As Global.System.Web.UI.WebControls.TextBox - + ''' '''RequiredFieldValidator19 control. ''' @@ -165,7 +174,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents RequiredFieldValidator19 As Global.System.Web.UI.WebControls.RequiredFieldValidator - + ''' '''cvCaptcha control. ''' @@ -174,7 +183,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents cvCaptcha As Global.System.Web.UI.WebControls.CustomValidator - + ''' '''captchaControl control. ''' @@ -183,7 +192,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents captchaControl As Global.MSCaptcha.CaptchaControl - + ''' '''lbtnRefreshCaptcha control. ''' @@ -192,7 +201,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents lbtnRefreshCaptcha As Global.System.Web.UI.WebControls.LinkButton - + ''' '''btnRegister control. ''' @@ -201,7 +210,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents btnRegister As Global.System.Web.UI.WebControls.Button - + ''' '''CaptchaUpdateProgress control. ''' @@ -210,7 +219,7 @@ Partial Public Class Register '''To modify move field declaration from designer file to code-behind file. ''' Protected WithEvents CaptchaUpdateProgress As Global.System.Web.UI.UpdateProgress - + ''' '''Master property. ''' @@ -219,7 +228,7 @@ Partial Public Class Register ''' Public Shadows ReadOnly Property Master() As GECO.MainLayout Get - Return CType(MyBase.Master,GECO.MainLayout) + Return CType(MyBase.Master, GECO.MainLayout) End Get End Property End Class diff --git a/GECO/Register.aspx.vb b/GECO/Register.aspx.vb index 19166a28..ca243ffc 100644 --- a/GECO/Register.aspx.vb +++ b/GECO/Register.aspx.vb @@ -16,6 +16,8 @@ Partial Class Register End Sub Protected Sub btnRegister_Click(sender As Object, e As EventArgs) Handles btnRegister.Click + Page.Validate() + If IsValid Then Dim email As String = txtEmail.Text.Trim() @@ -46,14 +48,84 @@ Partial Class Register txtCaptcha.Text = "" End Sub - Private Sub cvEmailExists_ServerValidate(source As Object, args As ServerValidateEventArgs) Handles cvEmailExists.ServerValidate + Protected Sub cvEmailExists_ServerValidate(source As Object, args As ServerValidateEventArgs) Handles cvEmailExists.ServerValidate args.IsValid = Not GecoUserExists(args.Value) End Sub - Private Sub cvCaptcha_ServerValidate(source As Object, args As ServerValidateEventArgs) Handles cvCaptcha.ServerValidate + Protected Sub cvCaptcha_ServerValidate(source As Object, args As ServerValidateEventArgs) Handles cvCaptcha.ServerValidate captchaControl.ValidateCaptcha(txtCaptcha.Text) txtCaptcha.Text = "" args.IsValid = captchaControl.UserValidated End Sub + Protected Sub passwordRequirement_ServerValidate(source As Object, args As ServerValidateEventArgs) Handles passwordRequirements.ServerValidate + If checkPasswordValid() Then + passwordRequirements.ErrorMessage = "The password cannot contain segments of the URL, app name, or email." + args.IsValid = False + End If + End Sub + + ''' + ''' Helper function for the passwordRequirement_ServerValidate() + ''' + ''' True if the password Is valid, false otherwise. + Private Function checkPasswordValid() As Boolean + Dim email As String = txtEmail.Text.ToLower + Dim password As String = txtPwd.Text.ToLower + + ' check if these passwords matches the email Or website + Dim validPassEmail As Integer = FindIntersection(email, password) + Dim validPassWebsite As Integer = FindIntersection("geco", password) + Dim validPassDepartment As Integer = FindIntersection("gaepd", password) + + ' declare an arbitrary length + Dim maxSequenceLength As Integer = 3 + Return validPassEmail <= maxSequenceLength AndAlso + validPassWebsite <= maxSequenceLength AndAlso + validPassDepartment <= maxSequenceLength + End Function + + ''' + ''' Find where the sequence starts And its length between 2 strings + ''' + ''' First string + ''' Second string + ''' 0 if there are no sequence, else return the length + Private Function FindIntersection(a As String, b As String) As Integer + Dim bestResult As Integer = 0 + For i As Integer = 0 To a.Length - 2 + Dim result As Integer = FindIntersectionFromStart(a.Substring(i), b) + If result <> 0 Then + If bestResult = 0 Then + bestResult = result + Else + If result > bestResult Then + bestResult = result + End If + End If + End If + If bestResult >= a.Length - i Then + Exit For + End If + Next + Return bestResult + End Function + + ''' + ''' Helper method for FindIntersection() + ''' + ''' First string + ''' Second string + ''' 0 if there are no sequence, else return the length + Private Function FindIntersectionFromStart(a As String, b As String) As Integer + For i As Integer = a.Length To 1 Step -1 + Dim d As String = a.Substring(0, i) + Dim j As Integer = b.IndexOf(d) + If j >= 0 Then + Return i ' return the length + End If + Next + Return 0 + End Function + End Class diff --git a/GECO/Web.configBuilder.xml b/GECO/Web.configBuilder.xml index adf6c0d6..cf35c757 100644 --- a/GECO/Web.configBuilder.xml +++ b/GECO/Web.configBuilder.xml @@ -137,7 +137,7 @@ - +