Verbesserung des new Passwort Generators.
This commit is contained in:
@@ -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},<br /><br />Your password is {1}.<br /><br />Thank You.", username, password)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user