Verbesserung des new Passwort Generators.
This commit is contained in:
@@ -9,15 +9,13 @@ Partial Class login_ForgotPW
|
|||||||
Inherits System.Web.UI.Page
|
Inherits System.Web.UI.Page
|
||||||
|
|
||||||
Protected Sub btn_Back_Click(sender As Object, e As EventArgs)
|
Protected Sub btn_Back_Click(sender As Object, e As EventArgs)
|
||||||
|
|
||||||
Response.Redirect("login/login_FLEX.aspx")
|
Response.Redirect("login/login_FLEX.aspx")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Protected Sub SendEmail(sender As Object, e As EventArgs)
|
Protected Sub SendEmail(sender As Object, e As EventArgs)
|
||||||
Dim username As String = txt_Username.Text
|
Dim username As String = txt_Username.Text
|
||||||
Dim password As String = String.Empty
|
Dim password As String = String.Empty
|
||||||
|
Dim email As String = txtEmail.Text
|
||||||
|
|
||||||
' cDBFunctions.GetNewOpenConnection()
|
' cDBFunctions.GetNewOpenConnection()
|
||||||
Dim ConnectionString = ""
|
Dim ConnectionString = ""
|
||||||
@@ -47,21 +45,22 @@ Partial Class login_ForgotPW
|
|||||||
End Using
|
End Using
|
||||||
|
|
||||||
If Not String.IsNullOrEmpty(username) Then
|
If Not String.IsNullOrEmpty(username) Then
|
||||||
' SendEmail(username, password)
|
password = RandomString(New Random, 10)
|
||||||
MsgBox("Mail would be sent successfully!")
|
'SendEmail(username, password, email)
|
||||||
|
MsgBox("Mail would be sent successfully!" + Environment.NewLine + "new PW: \t" + password)
|
||||||
lblMessage.ForeColor = Color.Green
|
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
|
Else
|
||||||
MsgBox("Mail would not be sent successfully!")
|
MsgBox("Mail would not be sent successfully!")
|
||||||
lblMessage.ForeColor = Color.Red
|
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 If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Function RandomString(r As Random)
|
Function RandomString(r As Random, max As Integer) As String
|
||||||
Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
Dim s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!§$%&/?="
|
||||||
Dim sb As New StringBuilder
|
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
|
For i As Integer = 1 To cnt
|
||||||
Dim idx As Integer = r.Next(0, s.Length)
|
Dim idx As Integer = r.Next(0, s.Length)
|
||||||
sb.Append(s.Substring(idx, 1))
|
sb.Append(s.Substring(idx, 1))
|
||||||
@@ -69,7 +68,7 @@ Partial Class login_ForgotPW
|
|||||||
Return sb.ToString()
|
Return sb.ToString()
|
||||||
End Function
|
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 Msg As New MailMessage
|
||||||
Dim myCredentials As New System.Net.NetworkCredential
|
Dim myCredentials As New System.Net.NetworkCredential
|
||||||
myCredentials.UserName = "al@verag.ag"
|
myCredentials.UserName = "al@verag.ag"
|
||||||
@@ -82,7 +81,7 @@ Partial Class login_ForgotPW
|
|||||||
mySmtpsvr.Credentials = myCredentials
|
mySmtpsvr.Credentials = myCredentials
|
||||||
Try
|
Try
|
||||||
Msg.From = New MailAddress("al@verag.ag")
|
Msg.From = New MailAddress("al@verag.ag")
|
||||||
Msg.To.Add(txtEmail.Text)
|
Msg.To.Add(email)
|
||||||
Msg.Subject = "TEST"
|
Msg.Subject = "TEST"
|
||||||
Msg.Body = String.Format("Hi {0},<br /><br />Your password is {1}.<br /><br />Thank You.", username, password)
|
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