From aa97daa486092532cce33caf1743699dd3ca5c2f Mon Sep 17 00:00:00 2001 From: ja Date: Wed, 6 Oct 2021 08:40:20 +0200 Subject: [PATCH] Verbesserung des new Passwort Generators. --- login/ForgotPW.aspx.vb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/login/ForgotPW.aspx.vb b/login/ForgotPW.aspx.vb index 6005033..79e3fd9 100644 --- a/login/ForgotPW.aspx.vb +++ b/login/ForgotPW.aspx.vb @@ -9,15 +9,13 @@ Partial Class login_ForgotPW Inherits System.Web.UI.Page Protected Sub btn_Back_Click(sender As Object, e As EventArgs) - Response.Redirect("login/login_FLEX.aspx") End Sub - - Protected Sub SendEmail(sender As Object, e As EventArgs) Dim username As String = txt_Username.Text Dim password As String = String.Empty + Dim email As String = txtEmail.Text ' cDBFunctions.GetNewOpenConnection() Dim ConnectionString = "" @@ -47,21 +45,22 @@ Partial Class login_ForgotPW End Using If Not String.IsNullOrEmpty(username) Then - ' SendEmail(username, password) - MsgBox("Mail would be sent successfully!") + password = RandomString(New Random, 10) + 'SendEmail(username, password, email) + MsgBox("Mail would be sent successfully!" + Environment.NewLine + "new PW: \t" + password) lblMessage.ForeColor = Color.Green - lblMessage.Text = "Password has been sent to your email address." + lblMessage.Text = "Passwort wurde erfolgreich an die angegebene E-Mail Adresse gesendet." Else MsgBox("Mail would not be sent successfully!") lblMessage.ForeColor = Color.Red - lblMessage.Text = "This email address does not match our records." + lblMessage.Text = "Diese E-Mail ist nicht in unserer Datenbank vorhanden." End If End Sub - Function RandomString(r As Random) - Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + Function RandomString(r As Random, max As Integer) As String + Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!ยง$%&/?=" Dim sb As New StringBuilder - Dim cnt As Integer = r.Next(15, 33) + Dim cnt As Integer = r.Next(4, max) For i As Integer = 1 To cnt Dim idx As Integer = r.Next(0, s.Length) sb.Append(s.Substring(idx, 1)) @@ -69,7 +68,7 @@ Partial Class login_ForgotPW Return sb.ToString() End Function - Function SendEmail(username As String, password As String) As Boolean + Function SendEmail(username As String, password As String, email As String) As Boolean Dim Msg As New MailMessage Dim myCredentials As New System.Net.NetworkCredential myCredentials.UserName = "al@verag.ag" @@ -82,7 +81,7 @@ Partial Class login_ForgotPW mySmtpsvr.Credentials = myCredentials Try Msg.From = New MailAddress("al@verag.ag") - Msg.To.Add(txtEmail.Text) + Msg.To.Add(email) Msg.Subject = "TEST" Msg.Body = String.Format("Hi {0},

Your password is {1}.

Thank You.", username, password)