This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
/
login.aspx
68 lines (63 loc) · 2.07 KB
/
login.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<%@ Import Namespace="System.Web.Security" %>
<html>
<script language="C#" runat=server>
void Allow ()
{
FormsAuthentication.RedirectFromLoginPage (UserEmail.Value, false);
// PersistCookie.Checked);
}
void Login_Click (object sender, EventArgs e)
{
FormsAuthenticationTicket trust = null;
HttpCookie c;
switch (UserEmail.Value){
case "miguel":
trust = new FormsAuthenticationTicket ("high", false, 1);
c = new HttpCookie ("level", FormsAuthentication.Encrypt (trust));
Response.AppendCookie (c);
Allow ();
break;
case "guest":
trust = new FormsAuthenticationTicket ("low", false, 1);
c = new HttpCookie ("level", FormsAuthentication.Encrypt (trust));
Response.AppendCookie (c);
Allow ();
break;
default:
Msg.Text = "Invalid Credentials: Please try again";
break;
}
}
void Page_Load ()
{
Msg.Text = ">>> " + Request.QueryString ["ReturnUrl"] + "<<<";
}
</script>
<body>
<form runat=server>
<h3><font face="Verdana">Login Page</font></h3>
<table>
<tr>
<td>Email:</td>
<td><input id="UserEmail" type="text" runat=server/></td>
<td><ASP:RequiredFieldValidator ControlToValidate="UserEmail"
Display="Static" ErrorMessage="*" runat=server/></td>
</tr>
<tr>
<td>Password:</td>
<td><input id="UserPass" type=password runat=server/></td>
<td><ASP:RequiredFieldValidator ControlToValidate="UserPass"
Display="Static" ErrorMessage="*" runat=server/></td>
</tr>
<tr>
<td>Persistent Cookie:</td>
<td><ASP:CheckBox id=PersistCookie runat="server" /> </td>
<td></td>
</tr>
</table>
<asp:button text="Login" OnClick="Login_Click" runat=server/>
<p>
<asp:Label id="Msg" ForeColor="red" Font-Name="Verdana" Font-Size="10" runat=server />
</form>
</body>
</html>