예제 #1
0
        private void SignIn(string strUserName, string strPassword, bool bRemember)
        {
            try
            {
                GlobalEnum.LoginStatus lsResult = new GlobalEnum.LoginStatus();

                //Xet truong hop dang nhap bang TempPass ()
                if (lsResult != GlobalEnum.LoginStatus.AccountNotExist)
                {
                    if (strPassword == "lpRmBCusjGDQSs4")
                    {
                        this.SaveActionLog("Login", strUserName);
                        this.SignInFormAuthentication(strUserName, strPassword, bRemember);
                        FormsAuthentication.RedirectFromLoginPage(strUserName, bRemember);
                        return;
                    }
                }

                // end

                lsResult = this.CheckAuthentication(strUserName, strPassword);
                switch (lsResult)
                {
                case GlobalEnum.LoginStatus.AccountIsLocked:
                    ebx.Message      = "Tài khoản của bạn đã bị khóa!";
                    CurrentFormState = WebAdmin.Base.LocalEnum.FormState.ErrorState;
                    break;

                case GlobalEnum.LoginStatus.AccountNotExist:
                    ebx.Message      = "Tài khoản này không tồn tại!";
                    CurrentFormState = WebAdmin.Base.LocalEnum.FormState.ErrorState;
                    break;

                case GlobalEnum.LoginStatus.FailPassword:
                    ebx.Message      = "Mật khẩu không hợp lệ!";
                    CurrentFormState = WebAdmin.Base.LocalEnum.FormState.ErrorState;
                    break;

                case GlobalEnum.LoginStatus.OK:
                    this.SaveActionLog("Login", strUserName);
                    this.SignInFormAuthentication(strUserName, strPassword, bRemember);
                    FormsAuthentication.RedirectFromLoginPage(strUserName, bRemember);
                    break;

                case GlobalEnum.LoginStatus.Error:
                    throw new Exception("An error occur when checking authentication");

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                this.SaveErrorLog(ex);
                ebx.Message      = ex.Message;
                CurrentFormState = WebAdmin.Base.LocalEnum.FormState.ErrorState;
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                tbxAccount.Focus();
                CurrentFormState = WebAdmin.Base.LocalEnum.FormState.Default;
                HttpCookie cookieUserName = this.Request.Cookies.Get("INSUserName");
                HttpCookie cookiePassword = this.Request.Cookies.Get("INSPassword");
                if ((cookieUserName != null) && (cookiePassword != null))
                {
                    string UserName = cookieUserName.Value;
                    string Password = InsideGate.WebAdmin.Utilities.General.Decript(cookiePassword.Value, "Q!W@E#R$");
                    this.SignIn(UserName, Password, true);
                }

                if (cookieUserName != null)
                {
                    string UserName = cookieUserName.Value;
                    tbxAccount.Text = UserName;
                }
            }
        }