Login System überarbeitet

This commit is contained in:
ja
2021-08-18 16:58:48 +02:00
parent e8051b672e
commit e5158343ad
4 changed files with 227 additions and 4 deletions

View File

@@ -25,7 +25,7 @@
-->
<system.web>
<authentication mode="Forms">
<forms defaultUrl="admin/admin.aspx" loginUrl="login/Login_TEST.aspx" slidingExpiration="true" timeout="2880" />
<forms defaultUrl="admin/admin.aspx" loginUrl="login/Login_TEST.aspx" slidingExpiration="true" timeout="2880" />
</authentication>
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false" controlRenderingCompatibilityVersion="4.0" />

151
login/Loggedin.aspx Normal file
View File

@@ -0,0 +1,151 @@
<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="Loggedin.aspx.vb" Inherits="login_login_TEST" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ import Namespace="MySql.Data.MySqlClient" %>
<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" />
<!-- <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;
}
#Login1_LoginButton{
color:#fff;
background-color:#003680;
}
@media (min-width: 768px) {
}
</style>
<script type="text/javascript">
function FocusOnInput() {
document.getElementById("UserID").focus();
}
</script>
<script type="text/javascript">
// Vergebe den Event-Handler
document.onkeydown = handleKeyEvent;
// Funktion, die den Event verarbeitet
function handleKeyEvent(e) {
// MSIE nimmt das Event-Objekt aus window.event, DOM-kompatible Browser aus dem e-Funktionsparameter
if (!e) e = window.event;
// keyCode muss 70 sein und ctrlKey true
if (e.keyCode == 68 && e.ctrlKey) {
alert('Strg+D wurde gedrückt');
//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]-->
<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);
}
</script>
</head>
<body onload="FocusOnInput()">
<!-- #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">
<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;">
<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>
<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>
<asp:Label ID="LBL2" runat="server">Willkommen zurück: </asp:Label>
</td>
<td>
<asp:LoginName ID="LoginName1" runat="server" />
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" required>Benutzername:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="Der Benutzername ist erforderlich." ToolTip="Der Benutzername ist erforderlich." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Kennwort:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Das Kennwort ist erforderlich." ToolTip="Das Kennwort ist erforderlich." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="left" colspan="2">
<br/> <asp:Button ID="LogoutButton" runat="server" CommandName="Logout" Text="Abmelden" ValidationGroup="Logout" target="frame" OnClientClick="bust1()"/>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</form>
</div>
</body>
</html>

61
login/Loggedin.aspx.vb Normal file
View File

@@ -0,0 +1,61 @@
Imports System.Data.SqlClient
Imports System.Data
Partial Class login_login_TEST
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
End Sub
Protected Sub LoginButton_Click(sender As Object, e As EventArgs)
End Sub
End Class

View File

@@ -1,4 +1,4 @@
<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="newpageJulius_Sidebar.aspx.vb" Inherits="_Default" %>
<%@ Page Language="VB" Debug="true" AutoEventWireup="false" CodeFile="newpageJulius_Sidebar.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html>
@@ -935,6 +935,7 @@
<!-- <a href="login/login_TEST.aspx" style="position:center;left:20px;top:10px;">LOGIN</a> -->
<form id="leftLinks" runat="server" style="float:initial">
<div class="align-self-center">
<!-- <a href="sendFeedback.aspx" toptions="type = iframe, effect = fade, width = 500, height = 500, overlayClose = 1,shaded=0, layout = flatlook" style='padding:0px;margin:0px;width:10px;height:10px;color:#fff;text-decoration: none;'>
<div class="feedback">
<div class="feedback_txt">Feedback
@@ -948,7 +949,17 @@
</div>
</div>
</a> -->
<iframe id="frame1" src="login/login_FLEX.aspx" runat="server" seamless="seamless" style="width:266px;height:219px;overflow:no-content;background-image:none;" scrolling="no" />
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<iframe id="frame1" src="login/login_FLEX.aspx" runat="server" seamless="seamless" style="width:266px;height:219px;overflow:no-content;background-image:none;" scrolling="no" />
</AnonymousTemplate>
<LoggedInTemplate>
<iframe id="frame1" src="login/Loggedin.aspx" runat="server" seamless="seamless" style="width:266px;height:219px;overflow:no-content;background-image:none;" scrolling="no" />
</LoggedInTemplate>
</asp:LoginView>
<!-- #include file="navigation.aspx" -->
<div id="main-page">
<!-- <div class="pagecontent"> -->