예제 #1
0
 protected void btnUpdate1_Click(object sender, EventArgs e)
 {
     try
     {
         RijndaelAES r      = new RijndaelAES();
         int         userid = Int32.Parse(Session["eStoreUserId"].ToString());
         User        us     = ebs.Users.Single(u => u.UserId == userid);
         if (txtOldPass.Text == r.Crypto(us.Pass, 1))
         {
             if (txtNewPass.Text == txtRePass.Text)
             {
                 us.Pass = r.Crypto(txtRePass.Text, 0);
                 ebs.SaveChanges();
             }
             else
             {
                 lblMsg.Text = "Passwords do not match.";
             }
         }
         else
         {
             lblMsg.Text = "Current password do not match.";
         }
     }
     catch (Exception ex)
     {
         lblErr.Text = ex.Message;
     }
 }
예제 #2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        String      login = txtLogin.Text.Trim();
        String      pass  = txtPass.Text;
        User        us    = ebs.Users.SingleOrDefault(u => u.UserLogin == login);
        RijndaelAES ri    = new RijndaelAES();

        if (us != null)
        {
            if (us.Pass == ri.Crypto(pass, 0))
            {
                Session["eStoreUser"]   = us.UserName.ToString();
                Session["eStoreUserId"] = us.UserId.ToString();
                if ((!System.Text.RegularExpressions.Regex.IsMatch(txtTimeOut.Text, @"(^([0-9]*|\d*\d{1}?\d*)$)")) || (txtTimeOut.Text.Trim() == ""))
                {
                    Session.Timeout = 20;
                }
                else
                {
                    Session.Timeout = Int32.Parse(txtTimeOut.Text);
                }
                Response.Redirect("../Home.aspx");
            }
            else
            {
                lblMsg.Text = "Incorrect Password.";
            }
        }
        else
        {
            lblMsg.Text = "User does not exist.";
        }
    }
예제 #3
0
 protected void btnReg_Click(object sender, EventArgs e)
 {
     try
     {
         ebs = new eBookStoreDBModelContainer();
         RijndaelAES ri           = new RijndaelAES();
         User        us           = new User();
         string      login        = txtLogin.Text;
         var         unique_check = from u in ebs.Users
                                    where u.UserLogin == login
                                    select u.UserName;
         if (txtPass.Text == txtrePass.Text)
         {
             if (unique_check.ToList().Count == 0)
             {
                 us.UserLogin = login;
                 us.UserName  = txtName.Text.Trim();
                 us.Pass      = ri.Crypto(txtPass.Text, 0);
                 us.Contact   = txtContact.Text;
                 ebs.Users.Add(us);
                 ebs.SaveChanges();
                 lblMsg.Text = "Successfully Registered. Redirecting now.";
                 Response.AddHeader("REFRESH", "2;URL=../Home.aspx");
             }
             else
             {
                 lblMsg.Text = "Cannot register. An account with this email already exists.";
             }
         }
         else
         {
             lblMsg.Text = "Passwords do not match.";
         }
     }
     catch (Exception ex)
     {
         lblErr.Text = ex.Message;
     }
 }