Esempio n. 1
0
        private void LogInProcedure()
        {
            try
            {
                string loginId       = inputEmail.Value.Trim();
                string typedPassword = inputPassword.Value.Trim();
                //bool isRemember = chkRemember.Checked;

                if (!string.IsNullOrEmpty(loginId) && !string.IsNullOrEmpty(typedPassword))
                {
                    User user = UserManager.UserGetByLoginId(loginId);

                    if (user != null)
                    {
                        string actualPassword = user.Password;
                        string encryptedPass  = Utilites.Encrypt(typedPassword);

                        if (actualPassword == encryptedPass)
                        {
                            Session["CurrentUser"] = null;
                            Session["CurrentUser"] = user;

                            string message   = "Login Success";
                            bool   isSuccess = true;
                            SaveLog(message, isSuccess);

                            Response.Redirect("~/Home.aspx", false);
                        }
                        else
                        {
                            string message   = "Password failer";
                            bool   isSuccess = false;
                            SaveLog(message, isSuccess);

                            //Response.Redirect("~/Login.aspx", false);
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert1", "Hello();", true);
                        }
                    }
                    else
                    {
                        string message   = "authentication failer";
                        bool   isSuccess = false;
                        SaveLog(message, isSuccess);

                        //Response.Redirect("~/Login.aspx", false);
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert1", "Hello();", true);
                    }
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Exception Occure');", true);
                //lblError.Text = ex.Message;

                string message   = "Exception";
                bool   isSuccess = false;
                SaveLog(message, isSuccess);
            }
        }