Example #1
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"));
        }