Änderungen auf neueres Design
This commit is contained in:
@@ -8,13 +8,6 @@ Imports System.Data
|
||||
Partial Class login_ForgotPW
|
||||
Inherits System.Web.UI.Page
|
||||
Protected Sub Page_Load(sender As Object, e As EventArgs)
|
||||
If txt_Username.Text = "" Then
|
||||
Try
|
||||
txt_Username.Text = Request.QueryString.Item("urlofchangepwpage")
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message)
|
||||
End Try
|
||||
End If
|
||||
End Sub
|
||||
Protected Sub btn_Back_Click(sender As Object, e As EventArgs)
|
||||
Response.Redirect("login/login_FLEX.aspx")
|
||||
@@ -25,9 +18,9 @@ Partial Class login_ForgotPW
|
||||
Dim password As String = String.Empty
|
||||
Dim email As String = txtEmail.Text
|
||||
Dim tokenname As String = ""
|
||||
' cDBFunctions.GetNewOpenConnection()
|
||||
Dim ConnectionString = ""
|
||||
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
|
||||
'cDBFunctions.GetNewOpenConnection()
|
||||
Dim ConnectionString = String.Empty
|
||||
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
|
||||
'ConnectionString = "Server=DEVELOPER\DEVSQL;Database=VERAG_HOMEPAGE;Uid=sa;Pwd=BmWr501956"
|
||||
ConnectionString = "Server=DEVELOPER\DEVSQL;Database=VERAG_HOMEPAGE;Uid=AppUser;Pwd=yp/THDd?xM+pZ$;"
|
||||
Else
|
||||
@@ -47,26 +40,21 @@ Partial Class login_ForgotPW
|
||||
If dr.Read() Then
|
||||
username = dr("Username").ToString()
|
||||
password = dr("Password").ToString()
|
||||
Try
|
||||
|
||||
email = txtEmail.Text
|
||||
|
||||
Catch ex As Exception
|
||||
Dim Msg, Style, Title As String
|
||||
Msg = "E-mail Prüfung fehlgeschlagen!" & vbCrLf + "Bitte erneut versuchen!"
|
||||
Style = vbRetry + vbExclamation + vbDefaultButton1
|
||||
Title = "Fehler bei E-mail Authentifizierung!"
|
||||
MsgBox(Msg, Style, Title)
|
||||
|
||||
If MsgBox(Msg, Style, Title).Yes Then
|
||||
txtEmail.Text = ""
|
||||
txtEmail.Focus()
|
||||
ElseIf MsgBox(Msg, Style, Title).No Then
|
||||
|
||||
End If
|
||||
End Try
|
||||
|
||||
End If
|
||||
Try
|
||||
email = txtEmail.Text
|
||||
Catch ex As Exception
|
||||
Dim Msg, Style, Title As String
|
||||
Msg = "E-mail Prüfung fehlgeschlagen!" & vbCrLf + "Bitte erneut versuchen!"
|
||||
Style = vbRetry + vbExclamation + vbDefaultButton1
|
||||
Title = "Fehler bei E-Mail Authentifizierung!"
|
||||
MsgBox(Msg, Style, Title)
|
||||
If MsgBox(Msg, Style, Title).Yes Then
|
||||
txtEmail.Text = String.Empty
|
||||
txtEmail.Focus()
|
||||
ElseIf MsgBox(Msg, Style, Title).No Then
|
||||
End If
|
||||
End Try
|
||||
End If
|
||||
End Using
|
||||
con.Close()
|
||||
End Using
|
||||
@@ -74,9 +62,8 @@ Partial Class login_ForgotPW
|
||||
If SendEmail(username, password, email, tokenname) = True Then
|
||||
'password = RandomString(New Random, 10)
|
||||
If (getDateoftoken(tokenname) = True) Then
|
||||
Dim msgboxstyle = vbDefaultButton1 + vbOK
|
||||
|
||||
MsgBox(tokenname, msgboxstyle)
|
||||
Dim msgboxstyle = vbDefaultButton1 + vbOK
|
||||
MsgBox(tokenname, msgboxstyle)
|
||||
Else
|
||||
MsgBox("token nicht mehr Gültig! Neuer wird generiert!")
|
||||
tokenname = genToken(username, password, email)
|
||||
@@ -104,20 +91,20 @@ Partial Class login_ForgotPW
|
||||
'End Function
|
||||
|
||||
Function SendEmail(username As String, password As String, email As String, tokenname As String) As Boolean
|
||||
Dim getdomianenvironment As String = ""
|
||||
Dim pagename As String = ""
|
||||
Dim ServPort As String = ""
|
||||
Dim getdomianenvironment As String = String.Empty
|
||||
Dim pagename As String = String.Empty
|
||||
Dim ServPort As String = String.Empty
|
||||
If HttpContext.Current.Request.ServerVariables("SERVER_NAME") = "localhost" Then
|
||||
getdomianenvironment = HttpContext.Current.Request.ServerVariables("SERVER_NAME")
|
||||
ServPort = ":" + Request.ServerVariables("SERVER_PORT")
|
||||
pagename = Request.ServerVariables("SCRIPT_NAME")
|
||||
'pagename = Request.ServerVariables("SCRIPT_NAME")
|
||||
ElseIf HttpContext.Current.Request.ServerVariables("SERVER_NAME") = Not "localhost" Then
|
||||
getdomianenvironment = HttpContext.Current.Request.ServerVariables("SERVER_NAME")
|
||||
ServPort = ":" + Request.ServerVariables("SERVER_PORT")
|
||||
pagename = Request.ServerVariables("SCRIPT_NAME")
|
||||
ServPort = String.Empty
|
||||
'pagename = Request.ServerVariables("SCRIPT_NAME")
|
||||
End If
|
||||
'Dim pg As String = Request.ServerVariables("URL")
|
||||
MsgBox("/" + ServPort + Request.ServerVariables("URL"))
|
||||
'MsgBox("/" + ServPort + Request.ServerVariables("URL"))
|
||||
Dim mailto As String = email
|
||||
Dim Betreff As String = "Passwort reset"
|
||||
Dim htmlbody = String.Format("Sehr geehrte/r {0},<br /><br /> Bitte dem Link zum Zurücksetzen des Passwortes folgen:<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 />Mit freundlichen Grüßen,", username, password)
|
||||
@@ -125,13 +112,13 @@ Partial Class login_ForgotPW
|
||||
Dim tokennametemp = genToken(username, password, email)
|
||||
'Dim Strtemp = Session.Keys.Item("urltochangepw")
|
||||
If getDateoftoken(tokennametemp) = True Then
|
||||
' Dim attachment As Attachment = New Attachment(File.OpenRead(excel), "Kundenliste.xlsx")
|
||||
' Msg.Attachments.Add(attachment)
|
||||
' Dim attachment As Attachment = New Attachment(File.OpenRead(excel), "Kundenliste.xlsx")
|
||||
' Msg.Attachments.Add(attachment)
|
||||
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(mailto, Betreff, htmlbody)
|
||||
MsgBox("SENT")
|
||||
Return True
|
||||
Else
|
||||
MsgBox("Error02: Mail not delivered!")
|
||||
MsgBox("Error02: Mail not delivered!" & vbCrLf & "Neuer Token wird generiert.")
|
||||
tokennametemp = genToken(username, password, email)
|
||||
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail(mailto, Betreff, htmlbody, tokenname)
|
||||
Return False
|
||||
@@ -146,13 +133,12 @@ Partial Class login_ForgotPW
|
||||
Dim time() As Byte = BitConverter.GetBytes(DateTime.UtcNow.ToBinary())
|
||||
Dim Key() As Byte = Guid.NewGuid().ToByteArray()
|
||||
Dim token As String
|
||||
|
||||
Try
|
||||
token = Convert.ToBase64String(time.Concat(Key).ToArray())
|
||||
Return token
|
||||
Catch Ex As Exception
|
||||
Dim Msg, Style, Title As String
|
||||
Msg = "Tokengenerierung fehlgeschlagen!" & vbCrLf & "Eine E-Mail wurde erneut an " + email + " zugesedet."
|
||||
Msg = "Tokengenerierung fehlgeschlagen!" & vbCrLf & "Eine E-Mail wurde erneut an " + email + " zugesendet."
|
||||
Style = vbRetry + vbExclamation + vbDefaultButton1
|
||||
Title = "Fehler bei Token-Generierung"
|
||||
MsgBox(Msg, Style, Title)
|
||||
@@ -160,16 +146,15 @@ Partial Class login_ForgotPW
|
||||
If MsgBox(Msg, Style, Title).Retry Then
|
||||
genToken(username, password, email)
|
||||
If SendEmail(username, password, email, token) = False Then
|
||||
MsgBox("Email konnte wegen eines internen Verschlüsselungsfehlers nicht gesendet werden.", vbOK + vbInformation + vbDefaultButton1, "TokengenerierungsFehler")
|
||||
MsgBox("Email konnte wegen eines internen Verschlüsselungsfehlers nicht gesendet werden.", vbOK + vbInformation + vbDefaultButton1, "Tokengenerierung-Fehler")
|
||||
Else
|
||||
MsgBox("Email wurde erfolgreich gesendet." & vbCr & "Bitte Postfach überprüfen!", vbOK + vbInformation + vbDefaultButton1, "Tokengenerierungs erfolgreich!")
|
||||
MsgBox("Email wurde erfolgreich gesendet." & vbCr & "Bitte Postfach überprüfen!", vbOK + vbInformation + vbDefaultButton1, "Tokengenerierung erfolgreich!")
|
||||
End If
|
||||
Else
|
||||
MsgBox("Tokengenerierung nicht erfolgreich." & vbCrLf & "In 5 Sekunden nochmal versuchen!")
|
||||
Dim jetzt As DateTime = DateTime.UtcNow
|
||||
Dim wenn As DateTime = DateTime.UtcNow.AddSeconds(-5)
|
||||
|
||||
|
||||
If jetzt < wenn Then
|
||||
Return "NotYet"
|
||||
Else
|
||||
@@ -180,12 +165,11 @@ Partial Class login_ForgotPW
|
||||
End Try
|
||||
End Function
|
||||
|
||||
|
||||
Function getDateoftoken(tokenname As String) As Boolean
|
||||
Dim data() As Byte = Convert.FromBase64String(tokenname)
|
||||
Dim wenn As DateTime = DateTime.FromBinary(BitConverter.ToInt64(data, 0))
|
||||
If wenn < DateTime.UtcNow.AddMinutes(-30) Then
|
||||
tokenname = ""
|
||||
tokenname = String.Empty
|
||||
MsgBox("Token nicht gefunden oder zu alt!" + Environment.NewLine + "Bitte erneut Mail senden!")
|
||||
Return False
|
||||
ElseIf tokenname = "NotYet" Then
|
||||
@@ -200,8 +184,4 @@ Partial Class login_ForgotPW
|
||||
Protected Sub txtEmail_TextChanged(sender As Object, e As EventArgs)
|
||||
regexval_txt_Email.Validate()
|
||||
End Sub
|
||||
|
||||
Protected Sub Token_tmr_Tick(sender As Object, e As EventArgs)
|
||||
btn_Send.Enabled = False
|
||||
End Sub
|
||||
End Class
|
||||
Reference in New Issue
Block a user