Login sowie Logout funktioniert

This commit is contained in:
ja
2021-09-29 14:40:17 +02:00
parent 727e261a1b
commit 433e61b32a
6 changed files with 102 additions and 230 deletions

View File

@@ -1,35 +1,32 @@
<%@ 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" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ import Namespace="MySql.Data.MySqlClient" %>
<head runat="server">
<!-- Bootstrap -->
<html lang="en"></html>
<!-- Required meta tags -->
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>VERAG Spedition AG Login</title>
<link rel="stylesheet" type="text/css" href="../css/main.css"/>
<link rel="stylesheet" type="text/css" href="../css/style.css"/>
<LINK REL="SHORTCUT ICON" HREF="../images/Icons/favicon/favicon.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" title="VERAG LoggedIn"/>
<link rel="shortcut icon" href="../images/Icons/favicon/favicon.ico" />
<!-- <link rel="stylesheet" type="text/css" href="css/edit_main.css"> -->
<script src="js/netzwerk.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="../../stylesheets/style.css"/>
<link rel="stylesheet" type="text/css" href="../../stylesheets/example.css"/>
<style>
body {
background-color: #fff;
background-image: none;
}
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous"/>
<link rel="stylesheet" type="text/css" href="../css/main.css"/>
<link rel="stylesheet" type="text/css" href="../css/style.css"/>
<link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.18.3/dist/bootstrap-table.min.css"/>
#Login1_LoginButton {
color: #fff;
background-color: #003680;
}
<!-- <link rel="stylesheet" type="text/css" href="css/edit_main.css"> -->
<script src="js/netzwerk.js" type="text/javascript"></script>
@media (min-width: 768px) {
}
</style>
<link rel="stylesheet" type="text/css" href="../css/style.css"/>
<link rel="stylesheet" type="text/css" href="../css/example.css"/>
<script type="text/javascript">
// Vergebe den Event-Handler
@@ -44,101 +41,33 @@
//topup
}
}
</script>
<!-- <script type="text/javascript" src="../js/toptions/top_up-min.js"></script> -->
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<![endif]-->
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<![endif]-->
<!--[if lte IE 5.5999]>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<![endif]-->
<!--[if gte IE 5.5]>
<link rel="stylesheet" type="text/css" href="../css/main.css">
<![endif]-->
<link rel="stylesheet" type="text/css" href="../css/login/LoggedIn.css"/>
</head>
<body onload="FocusOnInput()">
<!-- #include file="../navigation.aspx" -->
<div class="container-fluid" style="width:252px;height:216px;">
</script>
<style>
body{
background-image:none;
}
</style>
</head>
<body>
<div class="d-flex flex-row bd-highlight mb-3">
<div class="p-2 bd-highlight" style="width:252px;height:216px;align-content:flex-start;">
<form id="form1" runat="server">
<asp:Login ID = "Login1" runat = "server" OnAuthenticate= "ValidateUser">
<LayoutTemplate>
<table cellpadding="0" style="font-family:Arial;font-size:11px;border:1px solid gray">
<div>
<tr style=" background-image: linear-gradient(to right, #003680 , #0055cc);color:#fff;height:30px;font-size:12px">
<td align="center" colspan="2" style="color:#fff;font-kerning:auto;font-weight:700;">Erfolgreich eingeloggt!</td>
</tr>
<svg xmlns="http://www.w3.org/2000/svg" style="display: none; font-size:/*25px;*/ 1.990327332242226vh">
<symbol id="check-circle-fill" fill="currentColor" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
</symbol>
</svg>
<asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" ValidateRequestMode="Enabled"/>
<tr>
<td align="right">
<td>
<div class="alert alert-success align-items-center" role="alert" style="width:98%;">
<svg class="bi shrink-0 me-2" width="3.125vw" height="1.875vh" role="img" aria-label="Success:"><use xlink:href="#check-circle-fill"/></svg>
</td>
<tr> <td>
<asp:Label ID="LBL2" runat="server">Willkommen zurück: <%=Login1.UserName %> </asp:Label>
</td>
<td>
</td>
</tr>
</tr>
<tr>
<td>
<div style="height:10px;"></div>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<br/> <asp:Button id="LogoutButton" runat="server"/>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
<div style="height:32px;background-image: linear-gradient(to right, #003680 , #0055cc);color:#fff;">
<center><asp:Label ID="lbl_Loggedin" runat="server" Text="Logged In!" Style="font-weight:900"></asp:Label></center>
</div>
<h2> Willkommen zurück!</h2> <asp:LoginName ID="LoginName1" runat="server" />
<div class="row" id="BTN_World">
<div class="col-3">
<asp:LinkButton ID="LogoutButton" target="_top" href="../login/Logout.aspx" runat="server" CssClass="btn btn-primary" Text="Logout" />
</div>
<div style="height:/*15px*/1.17096018735363vh;"></div>
<div class="col-3">
</div>
</div>
</form>
</div>
</div>
<script type = "text/javascript">
function goBack() {
window.history.back()
}
</script>
<script>
function bust1() {
if (top != self)
setInterval("top.location.replace('../Kundenseite.aspx')", 1);
}
function bust2() {
if (top != self)
setInterval("top.location.replace('../admin/admin.aspx')", 1);
}
function bust3() {
if (top != self)
setInterval("top.location.replace('../newpageJulius_Sidebar.aspx')", 1);
}
</script>
</body>
</body>
</html>

View File

@@ -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

View File

@@ -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"%>
<!DOCTYPE html>
@@ -66,8 +66,9 @@
</script>
<style>
body {
background-color: #fff;
background-image: none;
background-color:#fff;
background-image:none;
}
#Login1_LoginButton {
@@ -81,11 +82,11 @@
</style>
</head>
<body onload="FocusOnInput()">
<body onload="FocusOnInput()" style="overflow-x:hidden;border:0px;margin:0px" >
<!-- #include file="../navigation.aspx" -->
<div class="container-fluid" style="width:252px;height:216px;">
<form id="form1" runat="server">
<asp:Login ID = "Login1" runat = "server" OnAuthenticate= "ValidateUser">
<asp:Login ID = "Login1" runat = "server" OnAuthenticate= "ValidateUser" ClientIDMode="AutoID">
<LayoutTemplate>
<table cellpadding="0" style="font-family:Arial;font-size:11px;border:1px solid gray">
<tr style=" background-image: linear-gradient(to right, #003680 , #0055cc);color:#fff;height:30px;font-size:12px">
@@ -130,10 +131,10 @@
</tr>
<tr>
<td align="left" colspan="2">
<br/> <asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Anmelden" ValidationGroup="Login1" target="_top" OnClientClick="bust1()"/>
<br/> <asp:LinkButton ID="LoginButton" runat="server" CommandName="Login" Text="Anmelden" ValidationGroup="Login1" PostBackUrl="~/newpageJulius_Sidebar.aspx"/>
</td>
<td align="middle" colspan="2">
<asp:LinkButton ID="LinkButton1" href="../login/login_TEST.aspx" runat="server" target="_top" OnClientClick="bust1()">Admin-Login</asp:LinkButton>
<asp:LinkButton ID="LinkButton1" runat="server" target="_top" OnClientClick="bust2">Admin-Login</asp:LinkButton>
</td>
</tr>
</table>
@@ -142,38 +143,14 @@
</form>
</div>
<script>
function bust1() {
if (window.top.location != window.location) {
var zipphone1_1 = getElementById("#CustomerID").val();
var zipphone1_2 = getElementById("#UserName").val();
var zipphone1_3 = getElementById("#Password").val();
alert("send:"+zipphone1_1)
alert("send:"+zipphone1_2)
alert("send:"+zipphone1_3)
postMessage(zipphone1_1,'*')
po
/*window.top.postMessage(getElementById("#CustomerID").val(),'*')
window.top.postMessage(getElementById("#UserName").val(), '*')
window.top.postMessage(getElementById("#Password").val(), '*')*/
//parent.location.replace('../Customers/Welcome.aspx');
top.location.replace('../Customers/Welcome.aspx');
}
}
<script type="text/javascript">
function bust2() {
if (top.location != self) {
var zipphone2_1 = getElementById("#CustomerID").val();
var zipphone2_2 = getElementById("#UserName").val();
var zipphone2_3 = getElementById("#Password").val();
alert("send:" + zipphone2_1)
alert("send:" + zipphone2_2)
alert("send:" + zipphone2_3)
//parent.location.replace('../Customers/Welcome.aspx');
top.location.replace('../Customers/Welcome.aspx');
}
alert("Funktion2");
if (top != self) {
top.onbeforeunload = function () { };
top.location = '../admin/admin.aspx';
}
</script>
</body>
</html>

View File

@@ -61,5 +61,6 @@ Partial Class login_login_TEST
Protected Sub LoginButton_Click(sender As Object, e As EventArgs)
End Sub
End Class

View File

@@ -19,6 +19,5 @@ Partial Class _Default
'cookie2.Expires = DateTime.Now.AddYears(-1)
'Response.Cookies.Add(cookie2)
Response.Redirect("login/Logout.aspx")
End Sub
End Class