/// <summary>
        /// BLL_GetName()方法,登录判断
        /// </summary>
        /// <param name="name">登录用户名</param>
        /// <param name="pwd">登录密码</param>
        /// <returns>是否登录成功</returns>
        public LoginState GetName(string name, string pwd)
        {
            DAL.Login login = new DAL.Login();
            Model.Student model = login.GetName(name);

            //把用户输入的pwd进行MD5转换,再与数据库得到的pwd(MD5加密后的)对比
            //1)添加引用;2)添加namespace:using System.Web.Security;
            pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "md5").ToLower();
            //微软提供的FormsAuthentication类的,HashPasswordForStoringInConfigFile()方法,会把加密后的MD5字符串自动
            //转成大写,故:要ToLower()

            if (model == null)
            {
                return LoginState.NoName;
            }
            else
            {
                if (model.Password == pwd)
                {
                    return LoginState.OK;
                }
                else
                {
                    return LoginState.IncorrectPwd;
                }
            }
        }
Exemple #2
0
        public bool SalvarLogLoginUsuario(List <MODEL.Usuario> ListaRetornoUsuarioLogado)
        {
            bool Retorno = false;

            DAL.Login DalLogAcesso = new DAL.Login();

            Retorno = DalLogAcesso.SalvarLogLoginUsuario(ListaRetornoUsuarioLogado);

            return(Retorno);
        }
        public async Task Delete_ShouldNotDeletePhysically()
        {
            Guid id = await UserRepository.Create(new API.User {
                FullName = "cica1", EmailOrUserName = "******"
            }, "mica1", Array.Empty <string>());

            Assert.DoesNotThrowAsync(() => UserRepository.Delete(id));
            Assert.ThrowsAsync <InvalidOperationException>(() => UserRepository.QueryById(id));

            DAL.User  user  = Connection.SingleById <DAL.User>(id);
            DAL.Login login = Connection.SingleById <DAL.Login>(user.LoginId);

            Assert.That(login.DeletedUtc, Is.Not.Null);
        }
        public void Create_ShouldCreateTheAppropriateEntries()
        {
            Guid id = Guid.Empty;

            Assert.DoesNotThrowAsync(async() => id = await UserRepository.Create(new API.User {
                FullName = "cica1", EmailOrUserName = "******"
            }, "mica1", Array.Empty <string>()));
            Assert.That(id, Is.Not.EqualTo(Guid.Empty));

            DAL.User user = Connection.SingleById <DAL.User>(id);

            Assert.That(user.FullName, Is.EqualTo("cica1"));
            Assert.That(user.LoginId, Is.Not.EqualTo(Guid.Empty));

            DAL.Login login = Connection.SingleById <DAL.Login>(user.LoginId);

            Assert.That(login.EmailOrUserName, Is.EqualTo("*****@*****.**"));
        }
        protected void btnResetPassword_Click(object sender, EventArgs e)
        {
            try
            {
                LoginBLL bll      = new LoginBLL();
                string   password = string.Empty;
                do
                {
                    password = System.Web.Security.Membership.GeneratePassword(10, 3);
                    if (bll.IsValidPasword(password))
                    {
                        break;
                    }
                } while (true);

                string    result = string.Empty;
                DAL.Login model  = bll.ResetPasswordPublic(txtName.Text, password, out result);
                // Send email with this new password
                if (result == "Password reseted successfully")
                {
                    try
                    {
                        EmailHelper.SendEmail(model.Email, "Hello " + txtName.Text + "," + "Your new password is : " + password, "Password Reseted. <br/>Best Regards,<br/>Realedge Support");
                    }
                    catch (Exception ex)
                    {
                        RadWindowManager1.RadAlert(ex.Message + " :: " + ex.InnerException.Message, 330, 180, "realedge associates", "alertCallBackFn");
                    }
                }

                //lblErrorMesage.Text = result;
                result = result.ToString().Replace("'", "");

                RadWindowManager1.RadAlert(result, 330, 180, "realedge associates", "alertCallBackFn");

                LogActivity("Password Reset", "User password has been reset", string.Empty);
            }
            catch (Exception ex)
            {
                //lblErrorMesage.Text = ex.Message;
                RadWindowManager1.RadAlert(ex.Message, 330, 180, "realedge associates", "alertCallBackFn");
                LogActivity("Password Reset(failure)", "User password has not been reset", ex.ToString());
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            LoginBLL bll = new LoginBLL();

            DAL.Login login = Session["LogedInUser"] as DAL.Login;
            if (login != null)
            {
                bll.SetLogin(login, 2);
                Session.Remove("LogedInUser");
                Session.Clear();
                Session.RemoveAll();
                GC.Collect();
                Response.Redirect("Login.aspx");
            }
            Session.Remove("LogedInUser");
            Session.Clear();
            Session.RemoveAll();
            GC.Collect();
            Response.Redirect("Login.aspx");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["LogedInUser"] != null && (Session["LogedInUser"] as DAL.Login) != null)
         {
             LogActivity("Loged Off", "Loged off from the system", string.Empty);
             DAL.Login login = Session["LogedInUser"] as DAL.Login;
             if (login != null)
             {
                 Session["LogedInUser"] = null;
                 Session.Abandon();
                 GC.Collect();
             }
             Response.Redirect("~/Login.aspx");
         }
     }
     Session.Clear();
     Session.RemoveAll();
     // Move back to the login page
     Response.Redirect("~/Login.aspx");
 }
Exemple #8
0
        public List <MODEL.Usuario> LogarUsuario(MODEL.Usuario Usuario)
        {
            try
            {
                // Declara retorno
                List <MODEL.Usuario> ListRetornoUsuario = new List <MODEL.Usuario>();

                // Valida o valor enviado


                // Após preencher o objeto enviar para DAL.
                DAL.Login DLogin = new DAL.Login();

                ListRetornoUsuario = DLogin.LogarUsuario(Usuario);

                return(ListRetornoUsuario);
            }
            catch (Exception)
            {
                throw;
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            int er = 0;

            ep.Clear();
            if (txtEmail.Text == "")
            {
                er++;
                ep.SetError(txtEmail, "Email / Contact Required");
            }
            if (txtPassword.Text == "")
            {
                er++;
                ep.SetError(txtPassword, "Required");
            }

            if (er > 0)
            {
                return;
            }

            DAL.Login lgn = new DAL.Login();

            lgn.Email    = txtEmail.Text;
            lgn.Password = txtPassword.Text;
            if (lgn.LoginCheck())
            {
                ACL.Login = lgn;

                this.Close();
            }
            else
            {
                MessageBox.Show("Invalid Login, Try Again");
                txtEmail.Focus();
            }
        }
Exemple #10
0
 public void LogarUsuario(string email, string pass)
 {
     DAL.Login bllLogin = new DAL.Login();
     bllLogin.LogarUsuario(email, pass);
 }
Exemple #11
0
        internal void SaveDependent(DAL.CustomersDataContext dc, DAL.Customer c)
        {
            DAL.Login dalLogin = null;

            if (this.Id == 0)
            {
                dalLogin = new CustomerManagement.DAL.Login();
                map(this, dalLogin);
                dalLogin.Customer = c;
                this.CustomerId = c.Id; // handles the case where the whole graph is saved with one Save() call
                dc.Logins.InsertOnSubmit(dalLogin);
            }
            else
            {
                dalLogin = dc.Logins.Where(record => record.Id == this.Id).Single();
                map(this, dalLogin);
            }

            dc.SubmitChanges();
            this.Id = dalLogin.Id;
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                LoginBLL bll = new LoginBLL();
                // check if the account is not locked
                bool?isLocked = bll.IsLocked(txtName.Text);
                if (isLocked == null)
                {
                    //lblErrorMesage.Text = "No user found with this Name (" + txtName.Text + ")";

                    RadWindowManager1.RadAlert("No user found with this Name (" + txtName.Text + ")", 330, 180, "realedge associates", "alertCallBackFn");

                    return;
                }
                else if (isLocked.Value)
                {
                    // lblErrorMesage.Text = "Your account has been blocked due to 3 failed login attempts. For unblock please contact administrator";

                    RadWindowManager1.RadAlert("Your account has been blocked due to 3 failed login attempts. For unblock please contact administrator", 330, 180, "realedge associates", "alertCallBackFn");

                    return;
                }

                // account is not locked
                DAL.Login model = bll.Authenticate(txtName.Text, txtPassword.Text);

                if (model != null)
                {
                    // Password will be expire after 60 days
                    if (model.LastPasswordReset.AddDays(60).Date <= DateTime.Now.Date)
                    {
                        // lblErrorMesage.Text = "Your password has been expired. Please contact administrator to reset your password";


                        btnResetPassword_Click(null, null);
                        RadWindowManager1.RadAlert("Your password has been expired. We sent you new password on your email address", 330, 180, "realedge associates", "alertCallBackFn");
                        return;
                    }
                    //else if (model.IsLogin == true && model.Role != "Admin")
                    //{
                    //    RadWindowManager1.RadAlert("This account is already logged on.", 330, 180, "realedge associates", "alertCallBackFn");
                    //    return;
                    //}
                    else
                    {
                        LogActivity("Login Successfull", "User Loged in successfully", string.Empty);
                        bll.SetLogin(model, 1);
                        Session["LogedInUser"] = model;
                        Response.Redirect("Default.aspx");
                    }
                }
                else
                {
                    //   lblErrorMesage.Text = "Please check Name and Password. You account will be blocked after 3 unsuccessfully attempts";
                    LogActivity("Login Error", "Please check Name and Password. You account will be blocked after 3 unsuccessfully attempts", string.Empty);
                    RadWindowManager1.RadAlert("Please check Name and Password. You account will be blocked after 3 unsuccessfully attempts", 330, 180, "realedge associates", "alertCallBackFn");
                }
            }
            catch (Exception ex)
            {
                LogActivity("Login Error", ex.Message, string.Empty);
                RadWindowManager1.RadAlert(ex.Message, 330, 180, "realedge associates", "alertCallBackFn");
            }
        }