Exemple #1
0
        public ActionResult Login(string email, string password)
        {
            string result;

            _user.Email    = email;
            _user.Password = password;
            try
            {
                //make implementation whether user has enter the details
                result = _ibac.IsValidUser(email, password);
                if (result != " ")
                {
                    Session["UserId"] = result;
                    return(RedirectToAction("Index", "Dashboard"));
                }
                else
                {
                    TempData["ErrorMessage"] = "Invalid User";
                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        IBusinessAuthentication iau = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance();

        try
        {
            string chkAcctNum = iau.IsValidUser(Utils.StripPunctuation(txtUsername.Text),
                                                Utils.StripPunctuation(txtPassword.Text));
            if (chkAcctNum != "")
            {
                lblStatus.Text                = "Welcome User";
                SessionFacade.USERNAME        = txtUsername.Text;
                SessionFacade.CHECKINGACCTNUM = chkAcctNum;
                if (SessionFacade.PAGEREQUESTED != null)
                {
                    Response.Redirect(SessionFacade.PAGEREQUESTED);
                }
            }

            else
            {
                lblStatus.Text = "Invalid User..";
            }
        }
        catch (Exception ex)
        {
            lblStatus.Text = ex.Message;
        }
    }
        public ActionResult Login(LoginModel Model, string ReturnUrl)
        {
            if (Model.Username == null || Model.Password == null)
            {
                // ModelState.AddModelError("Empty", "Username or Password Cannot be empty");
                ViewBag.Message = "Username or Password cannot be empty";
                return(View());
            }
            else
            {
                IBusinessAuthentication _IBusinessAuthentication = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance();

                string CheckingAccountNumber = _IBusinessAuthentication.IsValidUser(Model.Username, Model.Password);
                if (CheckingAccountNumber == null)
                {
                    ViewBag.Message = "Invalid User";
                    //ModelState.AddModelError("Valid", "Username or Password is not valid");
                    return(View());
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(CheckingAccountNumber, false);
                    if (ReturnUrl == "/" | ReturnUrl == null)
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        return(Redirect(ReturnUrl));
                    }
                }
            }
        }