Izenda-Guides.md
... ...
@@ -1,53 +0,0 @@
1
-#Authentication Function
2
-
3
-[[_TOC_]]
4
-
5
-##About
6
-
7
-This is a simple authentication function you can place in your Login page (Login.aspx in the default starter kit).
8
-
9
-Normally, logins should be pulled from the database, active directory, or whatever system your organization uses for storing user info. We also support using your company's existing login page in place of our example login page. If nothing is available, here is a simple method to provide basic authentication. Also included is the callback function used by **btnLogin**'s "OnClick" property.
10
-
11
-```csharp
12
-Bool AuthenticateUser(string userName, string password, out bool isAdmin)
13
-{
14
- System.Collections.Hashtable Passwords = new System.Collections.Hashtable();
15
- System.Collections.ArrayList Admins = new System.Collections.ArrayList();
16
-
17
- Passwords["Bob"]="password";
18
- Passwords["Steve"]="password";
19
- Passwords["Stacey"]="password";
20
- Passwords["Kim"]="password";
21
-
22
- Admins.Add("Bob");
23
- Admins.Add("Steve");
24
-
25
- if(Passwords[userName].Equals(password))
26
- {
27
- isAdmin = Admins.Contains(userName);
28
- return true;
29
- }
30
-
31
- // Could not authenticate
32
- return false;
33
-}
34
-void btnLogin_Click(object sender, EventArgs args)
35
-{
36
- loginValidator.IsValid = true;
37
- bool isAdmin;
38
- if (AuthenticateUser(userNameTextbox.Text, userPassword.Value, out isAdmin)) {
39
- HttpContext.Current.Session["UserName"] = userNameTextbox.Text;
40
- if (isAdmin)
41
- HttpContext.Current.Session["Role"] = "Admin";
42
- else
43
- HttpContext.Current.Session["Role"] = "RegularUser";
44
- global_asax.CustomAdHocConfig.InitializeReporting();
45
- Response.Redirect("ReportList.aspx");
46
- Page.Title = "Izenda - " + AdHocSettings.CurrentUserName;
47
- //FormsAuthentication.RedirectFromLoginPage(userNameTextbox.Text, false);
48
- return;
49
- }
50
- else
51
- loginValidator.IsValid = false;
52
-}
53
-```
... ...
\ No newline at end of file
Tutorials/CodeSamples/Login-Sample.md
... ...
@@ -0,0 +1,53 @@
1
+#Authentication Function
2
+
3
+[[_TOC_]]
4
+
5
+##About
6
+
7
+This is a simple authentication function you can place in your Login page (Login.aspx in the default starter kit).
8
+
9
+Normally, logins should be pulled from the database, active directory, or whatever system your organization uses for storing user info. We also support using your company's existing login page in place of our example login page. If nothing is available, here is a simple method to provide basic authentication. Also included is the callback function used by **btnLogin**'s "OnClick" property.
10
+
11
+```csharp
12
+Bool AuthenticateUser(string userName, string password, out bool isAdmin)
13
+{
14
+ System.Collections.Hashtable Passwords = new System.Collections.Hashtable();
15
+ System.Collections.ArrayList Admins = new System.Collections.ArrayList();
16
+
17
+ Passwords["Bob"]="password";
18
+ Passwords["Steve"]="password";
19
+ Passwords["Stacey"]="password";
20
+ Passwords["Kim"]="password";
21
+
22
+ Admins.Add("Bob");
23
+ Admins.Add("Steve");
24
+
25
+ if(Passwords[userName].Equals(password))
26
+ {
27
+ isAdmin = Admins.Contains(userName);
28
+ return true;
29
+ }
30
+
31
+ // Could not authenticate
32
+ return false;
33
+}
34
+void btnLogin_Click(object sender, EventArgs args)
35
+{
36
+ loginValidator.IsValid = true;
37
+ bool isAdmin;
38
+ if (AuthenticateUser(userNameTextbox.Text, userPassword.Value, out isAdmin)) {
39
+ HttpContext.Current.Session["UserName"] = userNameTextbox.Text;
40
+ if (isAdmin)
41
+ HttpContext.Current.Session["Role"] = "Admin";
42
+ else
43
+ HttpContext.Current.Session["Role"] = "RegularUser";
44
+ global_asax.CustomAdHocConfig.InitializeReporting();
45
+ Response.Redirect("ReportList.aspx");
46
+ Page.Title = "Izenda - " + AdHocSettings.CurrentUserName;
47
+ //FormsAuthentication.RedirectFromLoginPage(userNameTextbox.Text, false);
48
+ return;
49
+ }
50
+ else
51
+ loginValidator.IsValid = false;
52
+}
53
+```
... ...
\ No newline at end of file