Änderungen an sendeAlgorithmus

This commit is contained in:
ja
2021-10-13 15:03:13 +02:00
parent 5a184f95b1
commit 92fec23940

View File

@@ -61,12 +61,12 @@ Partial Class login_ForgotPW
Msg = "E-Mail validation failed!" & vbCrLf + "Please try again!" Msg = "E-Mail validation failed!" & vbCrLf + "Please try again!"
Style = vbRetry + vbExclamation + vbDefaultButton1 Style = vbRetry + vbExclamation + vbDefaultButton1
Title = "Authentication error!" Title = "Authentication error!"
MsgBox(Msg, Style, Title) 'MsgBox(Msg, Style, Title)
If MsgBox(Msg, Style, Title).Yes Then 'If MsgBox(Msg, Style, Title).Yes Then
txtEmail.Text = String.Empty 'txtEmail.Text = String.Empty
txtEmail.Focus() 'txtEmail.Focus()
ElseIf MsgBox(Msg, Style, Title).No Then 'ElseIf MsgBox(Msg, Style, Title).No Then
End If 'End If
End Try End Try
End If End If
End Using End Using
@@ -78,11 +78,16 @@ Partial Class login_ForgotPW
If SendEmail(username, password, email, tokenname) = True Then If SendEmail(username, password, email, tokenname) = True Then
'password = RandomString(New Random, 10) 'password = RandomString(New Random, 10)
If (getDateoftoken(tokenname) = True) Then If (getDateoftoken(tokenname) = True) Then
Dim msgboxstyle = vbDefaultButton1 + vbOK 'Dim msgboxstyle = vbDefaultButton1 + vbOK
'MsgBox(tokenname, msgboxstyle) 'MsgBox(tokenname, msgboxstyle)
MsgBox("Token generated successfully.") lblMessage.ForeColor = Color.Green
lblMessage.Text = "Token generated successfully."
'MsgBox("Token generated successfully.")
Else Else
MsgBox("Token is not valid anymore. Please generate a new one by sending a new e-mail!") lblMessage.ForeColor = Color.Red
lblMessage.Text = "Token is not valid anymore. Please generate a new one by sending a new e-mail!"
'MsgBox("Token is not valid anymore. Please generate a new one by sending a new e-mail!")
tokenname = genToken(username, password, email) tokenname = genToken(username, password, email)
End If End If
'SendEmail(username, password, email) 'SendEmail(username, password, email)
@@ -126,14 +131,14 @@ Partial Class login_ForgotPW
'pagename = Request.ServerVariables("SCRIPT_NAME") 'pagename = Request.ServerVariables("SCRIPT_NAME")
mailto = email mailto = email
Betreff = "Passwort reset" Betreff = "Passwort reset"
htmlbody = String.Format("Dear, {0},<br /><br /> Please follow the Link to reset your password:<br /><br /><br />.<br />" + Environment.NewLine + "<a runat=" + "server" + " href=http://" + getdomianenvironment + ServPort + "/login/ChangePW.aspx?Par1=" + VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(tokenname) + ">Link</a>" + Environment.NewLine + "<br />Kind regards, <br />VERAG | EDV Support<br />support@verag.ag,", username, password) htmlbody = String.Format("Dear, {0},<br /><br /> Please follow the Link to reset your password:<br /><br />" + Environment.NewLine + "<a runat=" + "server" + " href=http://" + getdomianenvironment + ServPort + "/login/ChangePW.aspx?Par1=" + VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(tokenname) + ">Link</a>" + Environment.NewLine + "<br />Kind regards, <br />VERAG | EDV Support<br />support@verag.ag,", username, password)
ElseIf String.IsNullOrWhiteSpace(HttpContext.Current.Request.ServerVariables("SERVER_NAME")) = False Then ElseIf String.IsNullOrWhiteSpace(HttpContext.Current.Request.ServerVariables("SERVER_NAME")) = False Then
getdomianenvironment = HttpContext.Current.Request.ServerVariables("SERVER_NAME") getdomianenvironment = HttpContext.Current.Request.ServerVariables("SERVER_NAME")
ServPort = String.Empty ServPort = String.Empty
'pagename = Request.ServerVariables("SCRIPT_NAME") 'pagename = Request.ServerVariables("SCRIPT_NAME")
mailto = email mailto = email
Betreff = "Passwort reset" Betreff = "Passwort reset"
htmlbody = String.Format("Dear, {0},<br /><br /> Please follow the Link to reset your password:<br /><br /><br />.<br />" + Environment.NewLine + "<a runat=" + "server" + " href=http://" + getdomianenvironment + "/login/ChangePW.aspx?Par1=" + VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(tokenname) + ">Link</a>" + Environment.NewLine + "<br />Kind regards, <br />VERAG | EDV Support<br />support@verag.ag,", username, password) htmlbody = String.Format("Dear, {0},<br /><br /> Please follow the Link to reset your password:<br /><br />" + Environment.NewLine + "<a runat=" + "server" + " href=http://" + getdomianenvironment + "/login/ChangePW.aspx?Par1=" + VERAG_PROG_ALLGEMEIN.cCryptography.Encrypt(tokenname) + ">Link</a>" + Environment.NewLine + "<br />Kind regards, <br />VERAG | EDV Support<br />support@verag.ag,", username, password)
ElseIf String.IsNullOrWhiteSpace(HttpContext.Current.Request.ServerVariables("SERVER_NAME")) = True Then ElseIf String.IsNullOrWhiteSpace(HttpContext.Current.Request.ServerVariables("SERVER_NAME")) = True Then
MsgBox("Error09:" + Environment.NewLine + " The Domain could not be vaildated. Check Link please or contact the Administrator of the program.") MsgBox("Error09:" + Environment.NewLine + " The Domain could not be vaildated. Check Link please or contact the Administrator of the program.")
End If End If
@@ -149,18 +154,22 @@ Partial Class login_ForgotPW
If String.IsNullOrEmpty(mailto) = False AndAlso String.IsNullOrEmpty(Betreff) = False AndAlso String.IsNullOrEmpty(htmlbody) = False Then If String.IsNullOrEmpty(mailto) = False AndAlso String.IsNullOrEmpty(Betreff) = False AndAlso String.IsNullOrEmpty(htmlbody) = False Then
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(mailto, Betreff, htmlbody) VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(mailto, Betreff, htmlbody)
Else Else
MsgBox("Error07: Die Paramter wurden nicht alle gesetzt. Bitte Felder überprüfen.", vbAbort, "Error07") 'MsgBox("Error07: Die Paramter wurden nicht alle gesetzt. Bitte Felder überprüfen.", vbAbort, "Error07")
lblMessage.ForeColor = Color.OrangeRed
lblMessage.Text = "Error07: Die Paramter wurden nicht alle gesetzt. Bitte Felder überprüfen!"
End If End If
MsgBox("SENT") MsgBox("SENT")
Return True Return True
Else Else
MsgBox("Error02: Mail not delivered!" & vbCrLf & "New Token has been generated.") lblMessage.ForeColor = Color.Red
lblMessage.Text = "Error02: Mail not delivered!"
'MsgBox("Error02: Mail not delivered!" & vbCrLf & "New Token has been generated.")
tokennametemp = genToken(username, password, email) tokennametemp = genToken(username, password, email)
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(mailto, Betreff, htmlbody, tokenname) VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(mailto, Betreff, htmlbody, tokenname)
Return False Return False
End If End If
Catch ex As Exception Catch ex As Exception
MsgBox(Err.Number & ex.Message & ex.StackTrace.ToString) 'Falls ein Fehler auftritt wird eine MsgBox angezeigt 'MsgBox(Err.Number & ex.Message & ex.StackTrace.ToString) 'Falls ein Fehler auftritt wird eine MsgBox angezeigt
End Try End Try
Return False Return False
End Function End Function
@@ -177,26 +186,26 @@ Partial Class login_ForgotPW
Msg = "Token Generation failed" & vbCrLf & "A new E-mail has been sent to the intern e-mail given." Msg = "Token Generation failed" & vbCrLf & "A new E-mail has been sent to the intern e-mail given."
Style = vbRetry + vbExclamation + vbDefaultButton1 Style = vbRetry + vbExclamation + vbDefaultButton1
Title = "Error05: Token-Generierung" Title = "Error05: Token-Generierung"
MsgBox(Msg, Style, Title) 'MsgBox(Msg, Style, Title)
If MsgBox(Msg, Style, Title).Retry Then 'If MsgBox(Msg, Style, Title).Retry Then
genToken(username, password, email) 'genToken(username, password, email)
If SendEmail(username, password, email, token) = False Then If SendEmail(username, password, email, token) = False Then
MsgBox("Email could not been sent because of an internal encryption error.", vbOK + vbInformation + vbDefaultButton1, "Token-Generation Error") 'MsgBox("Email could not been sent because of an internal encryption error.", vbOK + vbInformation + vbDefaultButton1, "Token-Generation Error")
Else
MsgBox("Email has been sent successful." & vbCr & "Please check your E-Mails!", vbOK + vbInformation + vbDefaultButton1, "Token-Generation successful!")
End If
Else Else
MsgBox("Token-Generation has not been successful." & vbCrLf & "Please try again in five seconds!") 'MsgBox("Email has been sent successful." & vbCr & "Please check your E-Mails!", vbOK + vbInformation + vbDefaultButton1, "Token-Generation successful!")
Dim jetzt As DateTime = DateTime.UtcNow End If
Dim wenn As DateTime = DateTime.UtcNow.AddSeconds(-5) 'Else
'MsgBox("Token-Generation has not been successful." & vbCrLf & "Please try again in five seconds!")
Dim jetzt As DateTime = DateTime.UtcNow
Dim wenn As DateTime = DateTime.UtcNow.AddSeconds(-5)
If jetzt < wenn Then If jetzt < wenn Then
Return "NotYet" 'Return "NotYet"
Else 'Else
token = Convert.ToBase64String(time.Concat(Key).ToArray()) token = genToken(username, password, email)
Return token Return token
End If 'End If
End If End If
End Try End Try
End Function End Function
@@ -206,7 +215,8 @@ Partial Class login_ForgotPW
Dim wenn As DateTime = DateTime.FromBinary(BitConverter.ToInt64(data, 0)) Dim wenn As DateTime = DateTime.FromBinary(BitConverter.ToInt64(data, 0))
If wenn < DateTime.UtcNow.AddMinutes(-30) Then If wenn < DateTime.UtcNow.AddMinutes(-30) Then
tokenname = String.Empty tokenname = String.Empty
MsgBox("Token has not been found or is too old!" + Environment.NewLine + "Please send a new E-mail!")
'MsgBox("Token has not been found or is too old!" + Environment.NewLine + "Please send a new E-mail!")
Return False Return False
ElseIf tokenname = "NotYet" Then ElseIf tokenname = "NotYet" Then
Return False Return False