Exemplo n.º 1
0
        public string LoginAuthenticate(CustomerAdminLogin cal)
        {
            CustomerAdminLogin calAuth = cal;

            Authenticator auth = new Authenticator();

            string username = calAuth.EnteredUsername;
            string password = calAuth.EnteredPassword;

            bool verified = auth.CheckHash(username, password);

            if (verified)
            {
                bool isAdmin = auth.IsAdminCheck(username);
                if (isAdmin == true)
                {
                    return("Admin Login Success");
                }
                else
                {
                    return("Login Success");
                }
            }
            else
            {
                return("Username or Password is incorrect!");
            }

            //return auth.generateHash(username, password);
        }
Exemplo n.º 2
0
        public ActionResult Login(CustomerAdminLogin cal)
        {
            if (ModelState.IsValid)
            {
                LoginRepository la           = new LoginRepository();
                string          authResponse = la.LoginAuthenticate(cal);

                string eusername = cal.EnteredUsername;

                ViewBag.LoginResponse = authResponse;


                if (authResponse.Equals("Login Success"))
                {
                    Session["username"] = eusername;
                    return(RedirectToAction("Index", "Home"));
                }
                else if (authResponse.Equals("Admin Login Success"))
                {
                    return(RedirectToAction("Orders", "Admin"));
                }
                else
                {
                    return(View());
                }
            }
            return(View());
        }