Exemplo n.º 1
0
        public int CheckIpWhiteList(string id, string Ip, string Mac, string location)
        {
            int             count = 0;
            var             res   = ValueController.GetIpTrue(id);
            ValueController vc    = new ValueController();

            if (res.Tables.Count != 0)
            {
                foreach (DataRow dr in res.Tables[0].Rows)
                {
                    if (Ip == dr[0].ToString())
                    {
                        count++;
                    }
                }
                if (count == 0)
                {
                    vc.PostActivityLog(id, "Login", "Failed");
                    var data2 = ModelManager.PostSecurityData(id, Ip, Mac, location);
                    //AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                    //return View("IPErrorPage");
                }
            }
            return(count);
        }
Exemplo n.º 2
0
        private ActionResult RedirectToLocal(string returnUrl, string id = null, string Ip = null, string Mac = null, string location = null, string Email = null)
        {
            var SessionaData = ValueController.GetSession(id);

            if (Url.IsLocalUrl(returnUrl))
            {
                if (SessionaData.IPAdressWhiteList)
                {
                    var rx = CheckIpWhiteList(id, Ip, Mac, location);
                    if (rx == 0)
                    {
                        AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                        return(View("IPErrorPage"));
                    }
                }
                return(Redirect(returnUrl));
            }
            // var userId = User.Identity.GetUserId();
            ValueController vc = new ValueController();


            if (SessionaData.DetectIP)
            {
                var res = ValueController.CheckIPAdress24(Ip, id);
                if (res == false)
                {
                    var data1 = ModelManager.PostSecurityData(id, Ip, Mac, location);
                    //SendMail obj = new SendMail();
                    SendMail.Mail(Email, "You are login with Ip Adress " + Ip + ". Is it you!");
                }
            }
            else if (SessionaData.IPAdressWhiteList)
            {
                var rx = CheckIpWhiteList(id, Ip, Mac, location);
                if (rx == 0)
                {
                    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                    return(View("IPErrorPage"));
                }
            }
            var data = ModelManager.PostSecurityData(id, Ip, Mac, location);

            vc.PostSessionToken();
            vc.PostActivityLog(id, "Login", "Succeed");
            return(RedirectToAction("Index", "Dashboard"));
        }