Advertisement
Ortund

Untitled

Apr 11th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. // App_Code/User.cs
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. using projectData;
  8.  
  9. /// <summary>
  10. /// Summary description for User
  11. /// </summary>
  12. public class User
  13. {
  14.     public int userid { get; protected set; }
  15.     public int storeid { get; protected set; }
  16.     public string emailaddress { get; protected set; }
  17.     public string password { get; protected set; }
  18.     public string role { get; protected set; }
  19.  
  20.     public User()
  21.     {
  22.         //
  23.         // TODO: Add constructor logic here
  24.         //
  25.     }
  26.  
  27.     public bool Login()
  28.     {
  29.         POSUser user = new POSUser(emailaddress, password);
  30.         user = user.Login();
  31.  
  32.         bool result = false;
  33.         if (user != null)
  34.         {
  35.             processLogin(user);
  36.         }
  37.  
  38.         return result;
  39.     }
  40.  
  41.     private void processLogin(POSUser loggedIn)
  42.     {
  43.         HttpContext.Current.Session["userid"] = loggedIn.userid;
  44.         HttpContext.Current.Session["storeid"] = loggedIn.storeid;
  45.         HttpContext.Current.Session["role"] = loggedIn.role;
  46.     }
  47. }
  48.  
  49. // ~/Login.cs
  50.  
  51. using System;
  52. using System.Collections.Generic;
  53. using System.Linq;
  54. using System.Web;
  55. using System.Web.UI;
  56. using System.Web.UI.WebControls;
  57.  
  58. public partial class Login : System.Web.UI.Page
  59. {
  60.     protected void Page_Load(object sender, EventArgs e)
  61.     {
  62.         if (!IsPostBack)
  63.         {
  64.             if (Context.User.Identity.IsAuthenticated)
  65.             {
  66.                 Response.Redirect("~/User/Default.aspx");
  67.             }
  68.         }
  69.     }
  70.     protected void btnLogin_Click(object sender, EventArgs e)
  71.     {
  72.         User. // Only User object in Intellisense is the Context.User object
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement