From 3f11532fa5ae57f7f2e6eb86c0483ca119599bc4 Mon Sep 17 00:00:00 2001 From: ja Date: Wed, 29 Sep 2021 14:40:17 +0200 Subject: [PATCH] Login sowie Logout funktioniert --- login/Loggedin.aspx | 195 +++++++++++----------------------- login/Loggedin.aspx.vb | 74 ++++--------- login/login_FLEX.aspx | 64 +++++------ login/login_FLEX.aspx.vb | 8 +- newpageJulius_Sidebar.aspx | 25 ++++- newpageJulius_Sidebar.aspx.vb | 6 +- 6 files changed, 133 insertions(+), 239 deletions(-) diff --git a/login/Loggedin.aspx b/login/Loggedin.aspx index fe51d42..8531fae 100644 --- a/login/Loggedin.aspx +++ b/login/Loggedin.aspx @@ -1,144 +1,73 @@ -<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="Loggedin.aspx.vb" Inherits="login_login_TEST" %> +<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Loggedin.aspx.vb" Inherits="login_Logged_IN" %> - - <%@ import Namespace="MySql.Data.MySqlClient" %> - - - VERAG Spedition AG Login - - - + + + + + + + + + + + + + + + + + + + - - - + + - - - - - - - - - - - - + + + + +
+
+
+ +
+
+
+

Willkommen zurück!

+
+
+ +
+
+
+
+
+ +
+
- - - - - -
-
- - - - -
-
- - - - - - - - - - - - - - - - - - - - - - -
Erfolgreich eingeloggt!
- -
- Willkommen zurück: <%=Login1.UserName %> - - -
-
-
-
-
-
-
-
-
- - - - + - diff --git a/login/Loggedin.aspx.vb b/login/Loggedin.aspx.vb index c91b271..e4dbd35 100644 --- a/login/Loggedin.aspx.vb +++ b/login/Loggedin.aspx.vb @@ -1,60 +1,26 @@ -Imports System.Data.SqlClient -Imports System.Data - -Partial Class login_login_TEST + +Partial Class login_Logged_IN Inherits System.Web.UI.Page - - Protected Sub ValidateUser(sender As Object, e As EventArgs) - Dim userId As Integer = 0 - ' cDBFunctions.GetNewOpenConnection() - Dim ConnectionString = "" - 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 - ConnectionString = "Server=DEVELOPER.verag.ost.dmn\DEVSQL;Database=VERAG_HOMEPAGE;Uid=AppUser;Pwd=yp/THDd?xM+pZ$;" - 'ConnectionString = "Server=db593295684.db.1and1.com;Database=db593295684;Uid=dbo593295684;Pwd=atilla#2;" - End If - - - ' Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString - Using con As New SqlConnection(ConnectionString) - ' Using cmd As New SqlCommand("Validate_User") - Using cmd As New SqlCommand("SELECT COUNT(*) FROM [VERAG_HOMEPAGE].[dbo].[Users] WHERE Username=@Username AND Password=@Password") - ' cmd.CommandType = CommandType.StoredProcedure - cmd.Parameters.AddWithValue("@Username", Login1.UserName) - cmd.Parameters.AddWithValue("@Password", Login1.Password) - cmd.Connection = con - con.Open() - ' userId = Convert.ToInt32(cmd.ExecuteScalar()) - Dim dr As SqlDataReader = cmd.ExecuteReader() - If dr.HasRows Then - dr.Read() - 'MsgBox(dr.Item(0).ToString()) - Select Case dr.Item(0) - Case 0 - Login1.FailureText = "Username and/or password is incorrect." - Exit Select - Case -2 - Login1.FailureText = "Account has not been activated." - Exit Select - Case Else - FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet) - 'FormsAuthentication.SetAuthCookie(Login1.UserName, True) - 'Response.Redirect("mypage.aspx") - Exit Select - End Select - End If - dr.Close() - con.Close() - End Using - End Using + Protected Sub Page_Load(sender As Object, e As EventArgs) + lbl_Loggedin.ForeColor = Drawing.Color.White + lbl_Loggedin.Style.Add("font-weight", "800") End Sub - - - Protected Sub LogoutButton_Click(sender As Object, e As EventArgs) FormsAuthentication.SignOut() - Response.Redirect("../login/Logout.aspx") + Session.Clear() + + 'clear authentication cookie + 'Dim cookie1 As HttpCookie = New HttpCookie(FormsAuthentication.FormsCookieName, "") + 'cookie1.Expires = DateTime.Now.AddYears(-1) + 'Response.Cookies.Add(cookie1) + + 'clear session cookie + 'Dim sessionStateSection As New SessionStateSection + 'SessionStateSection = WebConfigurationManager.GetSection("system.web/sessionState") + 'Dim cookie2 As HttpCookie = New HttpCookie(sessionStateSection.CookieName, "") + 'cookie2.Expires = DateTime.Now.AddYears(-1) + 'Response.Cookies.Add(cookie2) + + Response.Redirect("login/Logout.aspx") End Sub End Class diff --git a/login/login_FLEX.aspx b/login/login_FLEX.aspx index 7ddc327..3ce4eb3 100644 --- a/login/login_FLEX.aspx +++ b/login/login_FLEX.aspx @@ -1,4 +1,4 @@ -<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="login_FLEX.aspx.vb" Inherits="login_login_TEST" %> +<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="login_FLEX.aspx.vb" Inherits="login_login_TEST"%> @@ -66,8 +66,9 @@ - +
- + @@ -130,50 +131,33 @@
-
+
- Admin-Login + Admin-Login
-
- - - - + + + diff --git a/login/login_FLEX.aspx.vb b/login/login_FLEX.aspx.vb index 2720a2e..fc318a0 100644 --- a/login/login_FLEX.aspx.vb +++ b/login/login_FLEX.aspx.vb @@ -40,7 +40,7 @@ Partial Class login_login_TEST Case Else Session.Add("test", Login1.UserName) - CustomerIDTextBox = Login1.FindControl("CustomerID") + CustomerIDTextBox = Login1.FindControl("CustomerID") Session.Add("CustomerID", CustomerIDTextBox.Text) Session.Add("PW", Login1.Password) @@ -54,12 +54,6 @@ Partial Class login_login_TEST dr.Close() con.Close() End Using - End Using End Sub - - - - Protected Sub LoginButton_Click(sender As Object, e As EventArgs) - End Sub End Class diff --git a/newpageJulius_Sidebar.aspx b/newpageJulius_Sidebar.aspx index feddc9e..ed82a87 100644 --- a/newpageJulius_Sidebar.aspx +++ b/newpageJulius_Sidebar.aspx @@ -549,11 +549,13 @@ --> - +