Files
VERAG_Homepage/login/CreateUser.aspx.vb

78 lines
3.4 KiB
VB.net

Partial Class login_CreateUser
Inherits System.Web.UI.Page
Dim salt As Byte()
Dim initrandzahl As Integer
Protected Sub Page_Load(sender As Object, e As EventArgs)
If User.Identity.IsAuthenticated = False Then
FormsAuthentication.RedirectToLoginPage()
End If
If IsPostBack = True Then
Page.MaintainScrollPositionOnPostBack = True
VERAG_VARIABLES.initerrorcount()
Else
MaintainScrollPositionOnPostBack = False
VERAG_VARIABLES.initerrorcount()
End If
salt = VERAG_VARIABLES.GenerateSalt(VERAG_VARIABLES.RandomInteger(VERAG_VARIABLES.RandomInteger(0, Math.Pow(2, 6)), VERAG_VARIABLES.RandomInteger(Math.Pow(2, 7), Math.Pow(2, 10))))
initrandzahl = VERAG_VARIABLES.getiterationnumber
End Sub
Protected Sub LinkButton1_Click(sender As Object, e As EventArgs)
Dim validFileTypes As String() = {"bmp", "gif", "png", "jpg", "jpeg"}
Dim ext As String = System.IO.Path.GetExtension(FileUpload_Mobile.PostedFile.FileName)
Dim isValidFile As Boolean = False
For i As Integer = 0 To validFileTypes.Length - 1
If ext = "." & validFileTypes(i) Then
isValidFile = True
Exit For
End If
Next
If Not isValidFile Then
lblMessage_mob.ForeColor = System.Drawing.Color.Red
lblMessage_mob.Text = "Invalid File. Please upload a File with extension " &
String.Join(",", validFileTypes)
Else
lblMessage_mob.ForeColor = System.Drawing.Color.Green
lblMessage_mob.Text = "File uploaded successfully."
End If
End Sub
Protected Async Sub btn_Save_Changes_Click(sender As Object, e As EventArgs)
Dim validFileTypes As String() = {"bmp", "gif", "png", "jpg", "jpeg"}
Dim ext As String = System.IO.Path.GetExtension(FileUpload_Desktop.PostedFile.FileName)
Dim isValidFile As Boolean = False
Dim pathtosave As String = String.Empty
For i As Integer = 0 To validFileTypes.Length - 1
If ext = "." & validFileTypes(i) Then
pathtosave = "../images/users/" + Me.Page.User.Identity.Name + "/ImageProf"
isValidFile = True
Exit For
End If
Next
If Not isValidFile Then
lbl_message_desktop.ForeColor = System.Drawing.Color.Red
lbl_message_desktop.Text = "Invalid File. Please upload a File with extension " &
String.Join(",", validFileTypes)
Else
FileUpload_Desktop.PostedFile.SaveAs(pathtosave + "/" + Date.Now.ToShortDateString + "." + System.IO.Path.GetExtension(FileUpload_Desktop.PostedFile.FileName))
lbl_message_desktop.ForeColor = System.Drawing.Color.Green
lbl_message_desktop.Text = "File uploaded successfully."
End If
If String.IsNullOrEmpty(txt_PW.Text) = False AndAlso String.IsNullOrEmpty(txt_PW_WH.Text) = False Then
Dim hashpw As Byte() = Await VERAG_VARIABLES.HashPassword(txt_PW_WH.Text, salt, initrandzahl, VERAG_VARIABLES.RandomInteger(0, Math.Pow(2, 7)))
End If
End Sub
Protected Sub FileUpload_Mobile_Init(sender As Object, e As EventArgs)
If FileUpload_Mobile.HasFile = True Then
lblMessage_mob.Text = FileUpload_Mobile.FileName
Else
'FileUpload_Mobile.
End If
End Sub
End Class