示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["LogedInUser"] != null && (Session["LogedInUser"] as DAL.Login) != null)
         {
             DAL.Login login = Session["LogedInUser"] as DAL.Login;
             if (login != null)
             {
                 lblUserName.Text = login.Name;
                 LoansBLL loanBLL = new LoansBLL();
                 lblDetails.InnerText = DateTime.Now.ToString() + " - " + loanBLL.GetLoanCount() + " Records in Loans DB";
                 // Show the Admin tab only to Administrator role
                 if (login.Role == AppConstants.Roles.Admin.ToString() && !string.IsNullOrEmpty(Request.Path))
                 {
                     hlAdministration.Visible = true;
                     if (Request.Path.Contains("Administration"))
                     {
                         hlAdministration.Text        = "Main";
                         hlAdministration.NavigateUrl = "~/Default.aspx";
                         lblAdministration.Visible    = true;
                     }
                     else if (Request.Path.Contains("/administration.aspx"))
                     {
                         hlAdministration.Text        = "Main";
                         hlAdministration.NavigateUrl = "~/Default.aspx";
                         lblAdministration.Visible    = true;
                     }
                     else
                     {
                         hlAdministration.Text        = "Administration";
                         hlAdministration.NavigateUrl = "~/Administration.aspx";
                     }
                 }
                 else
                 {
                     hlAdministration.Visible  = false;
                     lblAdministration.Visible = false;
                 }
             }
         }
     }
 }
示例#2
0
        public ActionResult Index(User l)
        {
            int kq = new DAL.Login().login(l.Id, l.Pass);

            if (kq == 0)
            {
                ModelState.AddModelError("", "Đăng nhập không thành công");
            }
            else
            {
                //UserSesstion s = new UserSesstion
                //{
                //    Username = l.Id
                //};
                // getSesstion.SetSesstion(s);
                Session["login"] = l.Id;
                return(RedirectToAction("home", "Test"));
            }
            return(View(l));
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Logins EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLogins(Login login)
 {
     base.AddObject("Logins", login);
 }
 /// <summary>
 /// Create a new Login object.
 /// </summary>
 /// <param name="userName">Initial value of the UserName property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="id">Initial value of the Id property.</param>
 public static Login CreateLogin(global::System.String userName, global::System.String password, global::System.Int32 id)
 {
     Login login = new Login();
     login.UserName = userName;
     login.Password = password;
     login.Id = id;
     return login;
 }
示例#5
0
        //Update

        public void UpdateLogin(Login Login)
        {
            dataConnector.Update("UPDATE `login` SET `Username` = '" + Login.UserName + "', `Password` = '" + Login.HashedPassword + "', `Salt` = '" + Login.Salt + "' WHERE `Login`.`ID` = " + Login.ID + ";");
        }
示例#6
0
 //Create
 public Login CreateLogin(Login Login)
 {
     dataConnector.Insert("INSERT INTO `login` (`ID`, `Username`, `Password`, `Salt`) VALUES (NULL, '" + Login.UserName + "', '" + Login.HashedPassword + "', '" + Login.Salt + "');");
     return(GetLogin(Login));
 }
示例#7
0
 public void DeleteLogin(Login Login)
 {
     DeleteLogin(Login.ID);
 }
 /// <summary>
 /// Create a new Login object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="role">Initial value of the Role property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 /// <param name="isLocked">Initial value of the IsLocked property.</param>
 /// <param name="failedAttempts">Initial value of the FailedAttempts property.</param>
 /// <param name="lastPasswordReset">Initial value of the LastPasswordReset property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 public static Login CreateLogin(global::System.Int32 id, global::System.String name, global::System.String password, global::System.String role, global::System.Int32 status, global::System.Boolean isLocked, global::System.Int32 failedAttempts, global::System.DateTime lastPasswordReset, global::System.DateTime createdDate)
 {
     Login login = new Login();
     login.ID = id;
     login.Name = name;
     login.Password = password;
     login.Role = role;
     login.Status = status;
     login.IsLocked = isLocked;
     login.FailedAttempts = failedAttempts;
     login.LastPasswordReset = lastPasswordReset;
     login.CreatedDate = createdDate;
     return login;
 }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            LoginBLL bll = new LoginBLL();

            if (bll.IsValidPasword(txtPassword.Text))
            {
                DAL.Login model = new DAL.Login();

                model.CreatedDate = DateTime.Now;
                model.FailedAttempts = 0;
                model.IsLocked = false;
                model.LastPasswordReset = DateTime.Now;
                model.Name = txtName.Text;
                model.Password = txtPassword.Text;
                model.Role = AppConstants.Roles.Normal.ToString();
                model.Status = 1;
                model.Email = txtCreatUserEmail.Text;
                model = bll.NewAccount(model);

                lblError.Visible = false;

                if (model == null)
                {
                    ShowMessage("Error", "User with the same name already exist");
                    return;
                }

                BindAccounts();

                LogActivity("User Created", "New user has been created", string.Empty);
            }
            else
            {
                lblError.Visible = true;
                lblError.Text = "Password must be 8 to 15 characters long which contain at least one lowercase letter, one uppercase letter, one numeric digit, and one special character";
            }
        }