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;
        }
    }
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        string username = txtusername.Text;
        string password = txtpassword.Text;
        IBusinessAuthentication ibau = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance();

        string acceslevel = ibau.isValidUser(username, password);

        if (acceslevel != "")
        {
            string roles = ibau.GetRolesForUser(username);
            FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddMinutes(30), false, roles);
            string     encryptedTicket           = FormsAuthentication.Encrypt(authTicket);
            HttpCookie authCookie = new HttpCookie
                                        (FormsAuthentication.FormsCookieName, encryptedTicket);
            Response.Cookies.Add(authCookie);

            //FormsAuthentication.RedirectFromLoginPage(username.ToString(), true);
            SessionFacade.USERNAME = username;
            SessionFacade.ROLE     = roles;
            Response.Redirect(FormsAuthentication.GetRedirectUrl(username, true));
        }
        else
        {
            lblStatus.Text = "Invalid login for Requested Page";
        }
    }
        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));
                    }
                }
            }
        }
Exemple #4
0
        protected override void Initialize(RequestContext requestContext)
        {
            if (AuthService == null)
            {
                AuthService = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance();
            }

            base.Initialize(requestContext);
        }
 public LoginModel(SignInManager <IdentityUser> signInManager,
                   ILogger <LoginModel> logger,
                   UserManager <IdentityUser> userManager, IBusinessAuthentication businessAuth)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     _logger        = logger;
     _businessAuth  = businessAuth;
 }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            try
            {
                string             uname    = txtUsername.Text;
                string             fname    = txtFirstName.Text;
                string             lname    = txtLastName.Text;
                string             street   = txtAddress.Text;
                string             city     = txtCity.Text;
                string             state    = txtState.Text;
                string             zipcode  = txtZipcode.Text;
                string             email    = txtEmail.Text;
                string             ccnum    = txtCCNumber.Text;
                string             expdate  = txtCCExpiration.Text;
                string             cctype   = ddlCCType.SelectedItem.ToString();
                string             password = txtPW.Text;
                string             phint    = txtPWHintQ.Text;
                string             pAns     = txtPWHintA.Text;
                IBusinessFunctions ibf      = GenericFactory <BusinessLayer, IBusinessFunctions> .CreateInstance();

                IBusinessAuthentication ibu = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance();

                bool isvalidUsername = ibf.checkUsername(uname);
                if (isvalidUsername)
                {
                    lblStatus.Text = "Please choose a different Username as this already exists";
                    throw new Exception("duplicate username");
                }
                else
                {
                    int    regusers      = ibf.RegisterUsers(uname, password, phint, pAns);
                    string userId        = ibu.isValidUser(uname, password);
                    int    rows_affected = ibf.RegisterCustomer(userId, fname, lname, street, city, state, zipcode, ccnum, cctype, expdate, email);
                    if (rows_affected > 0)
                    {
                        SessionFacade.CUSTOMERID = userId;
                        Response.Redirect("ConfirmCheckOut.aspx");
                    }
                }
            }
            catch (Exception ex)
            {
                lblStatus.Text = ex.Message;
            }
        }
    }
Exemple #7
0
        public ActionResult Login(LoginModel lm)
        {
            IBusinessAuthentication iba = GenericFactory <Business, IBusinessAuthentication> .GetInstance();

            IBusinessBanking ibank = GenericFactory <Business, IBusinessBanking> .GetInstance();

            IBusinessLoan iloan = GenericFactory <Business, IBusinessLoan> .GetInstance();

            if (ModelState.IsValid)
            {
                // check if valid user
                bool ret = iba.CheckIfValidUser(lm.Username, lm.Password);
                if (ret == true)
                {
                    string roles = iba.GetRolesForUser(lm.Username);
                    // send the pipedelimited roles as an authentication cookie back to the browser
                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, lm.Username, DateTime.Now, DateTime.Now.AddMinutes(15), false, roles);
                    string     encryptedTicket           = FormsAuthentication.Encrypt(authTicket);
                    HttpCookie ck = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    Response.Cookies.Add(ck);
                    // ----obtaing checking account number and saving account number for user
                    long     checkingAccountNum  = ibank.GetCheckingAccountNumForUser(lm.Username);
                    long     savingAccountNumber = ibank.GetSavingAccountNumForUser(lm.Username);
                    UserInfo ui = new UserInfo();
                    ui.CheckingAcccountNumber = checkingAccountNum;
                    ui.SavingAccountNumber    = savingAccountNumber;
                    ui.Username = lm.Username;
                    //HttpCookie ckuser = new HttpCookie("UserInfo");
                    //ckuser["USERDATA"] = ui.LosSerialize();
                    //Response.Cookies.Add(ckuser);
                    CookieFacade.USERINFO = ui;
                    CacheAbstraction cabs = new CacheAbstraction();
                    cabs.Remove("TRHISTORY" + ":" + checkingAccountNum);
                    //----------------------------------------------------
                    string redirectURL = FormsAuthentication.GetRedirectUrl(lm.Username, false);
                    if (redirectURL == "/default.aspx")
                    {
                        redirectURL = "~/home/index";
                    }
                    //Response.Redirect(redirectURL);
                    // causes antiforgery token exception
                    return(Redirect(redirectURL));
                }
                ViewBag.Message = "Invalid login..";
            }
            return(View(lm));
        }
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        IBusinessAuthentication ibau = GenericFactory <BusinessLayer, IBusinessAuthentication> .CreateInstance();

        try
        {
            string username = ibau.isValidUser(Utils.StripPunctuation(txtusername.Text), Utils.StripPunctuation(txtpassword.Text));

            if (username != null)
            {
                SessionFacade.CUSTOMERID = username;
                lblStatus.Text           = "Welcome " + txtusername.Text;
                Response.Redirect("ConfirmCheckOut.aspx");
            }
            else
            {
                lblStatus.Text = "Invalid User";
            }
        }
        catch (Exception ex)
        {
            lblStatus.Text = ex.Message;
        }
    }
 public AuthenticationController()
 {
     this.reportAuthentication   = ObjectFactory.GetInstance <IReportAuthentication>();
     this.businessAuthentication = ObjectFactory.GetInstance <IBusinessAuthentication>();
 }