コード例 #1
0
        //[HttpPost]
        public ActionResult ResetPassword(string token)
        {
            if (token.Contains(" "))
            {
                token = token.Replace(" ", "+");
            }
            string EncryptToken = "";

            try
            {
                EncryptToken = Convert.ToString(SecurityHelperService.Decrypt(token));
                //EncryptToken = token;
            }
            catch (Exception ex) { }
            string[] strlist = EncryptToken.Split(new[] { "~", "##" }, StringSplitOptions.RemoveEmptyEntries);

            DateTime tokendate = Convert.ToDateTime(strlist[2]);
            double   totaldays = (DateTime.Now - tokendate).TotalDays;

            if (totaldays > 2)
            {
                return(RedirectToAction("TokenExpired", "Account"));
            }
            else
            {
                IEnumerable <GetEmailId> cm = _lookUpRepository.GetEmailId(int.Parse(strlist[0]), strlist[1]);
                ViewBag.Username = cm.ElementAt(0).EmailID;
                ViewBag.role     = strlist[1];
                return(View());
            }
        }
コード例 #2
0
 private void AssignedCookieValue()
 {
     try
     {
         HttpContext.Session.SetInt32("UserID", Convert.ToInt32(SecurityHelperService.Decrypt(Request.Cookies["UserID"])));
         HttpContext.Session.SetString("UserName", Convert.ToString(SecurityHelperService.Decrypt(Request.Cookies["UserName"])));
         HttpContext.Session.SetString("Role", Convert.ToString(SecurityHelperService.Decrypt(Request.Cookies["Role"])));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #3
0
 /// <summary>
 /// Get cookie method
 /// </summary>
 /// <param name="UserID"></param>
 /// <param name="UserName"></param>
 /// <param name="UserRole"></param>
 public void GetCookie(out string UserID, out string UserName, out string UserRole)
 {
     UserID   = string.Empty;
     UserName = string.Empty;
     UserRole = string.Empty;
     try
     {
         if (Request.Cookies["UserID"] == null)
         {
             UserID   = SecurityHelperService.Decrypt(Request.Cookies["UserID"].ToString());
             UserName = SecurityHelperService.Decrypt(Request.Cookies["UserName"].ToString());
             UserRole = SecurityHelperService.Decrypt(Request.Cookies["UserRole"].ToString());
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #4
0
        public IActionResult ValidateAdminLogOn(string PANNumber, string Password, string IsRemember)
        {
            if (!ReCaptchaPassed(
                    Request.Form["g-recaptcha-response"], // that's how you get it from the Request object
                    _configuration.GetSection("GoogleReCaptcha:SecretKey").Value
                    ))
            {
                TempData["InvalidCredential"] = "Captcha verification failed.";
                return(RedirectToAction("AdminLogin", "Account"));
            }

            string pw = SecurityHelperService.Decrypt("9b1L+4cRvb5EYXkEw8dl3bgkBFnKqjSQ");

            string InputCredential = PANNumber;
            string Controller      = "";
            string ActionName      = "";

            Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$");
            Match match = regex.Match(InputCredential);

            Password = SecurityHelperService.Encrypt(Password);
            AdminLoginModel objDatawithSP = _adminRepository.FindName(PANNumber, Password);

            if (objDatawithSP == null)
            {
                string strLockRes = _adminRepository.LockedAdminUser(PANNumber);
                TempData["InvalidCredential"] = strLockRes;
                return(RedirectToAction("AdminLogin", "Account"));
            }
            else
            {
                var AdminID      = objDatawithSP.CompanyID;
                var AdminName    = objDatawithSP.ContactPersonName;
                var InternalRole = objDatawithSP.Role;
                var companyname  = objDatawithSP.Name;

                CookieOptions option = new CookieOptions();
                option.Expires = DateTime.Now.AddDays(2);
                Response.Cookies.Append("RoleAccess", "AdminLogin", option);


                TempData["InternalRole"] = InternalRole;
                HttpContext.Session.SetInt32("UserID", AdminID);
                HttpContext.Session.SetString("LoginName", AdminName);
                HttpContext.Session.SetString("Role", "MasterAdmin");
                HttpContext.Session.SetString("CompanyType", InternalRole);
                HttpContext.Session.SetString("Companyname", companyname);
                HttpContext.Session.SetString("JWToken", GenerateJWTToken(AdminName));
                //HttpContext.Session.SetString("RoleAccess", RoleAccess);
                if (objDatawithSP.IsTemporaryPassword == false)
                {
                    TempData["Role"] = "MasterAdmin";

                    if (IsRemember == "1")
                    {
                        SetCookie(AdminID.ToString(), AdminName, "MasterAdmin");
                        Response.Cookies.Append("PANNumber", PANNumber, option);
                    }
                    return(RedirectToAction("UserList", "User"));
                }
                else
                {
                    var data = Encoding.UTF8.GetBytes("MasterAdmin");
                    var Role = Convert.ToBase64String(data);
                    Controller = "Common";
                    ActionName = "ChangePassword";

                    HttpContext.Session.SetString("Email", objDatawithSP.PANNumber);

                    if (IsRemember == "1")
                    {
                        SetCookie(AdminID.ToString(), AdminName, "MasterAdmin");
                        Response.Cookies.Append("PANNumber", PANNumber, option);
                    }
                    return(RedirectToAction(ActionName, Controller, new { RoleName = Role }));
                }
            }
        }
コード例 #5
0
        public IActionResult ValidateUserLogOn(string Email, string Password, string IsRemember)
        {
            if (!ReCaptchaPassed(
                    Request.Form["g-recaptcha-response"], // that's how you get it from the Request object
                    _configuration.GetSection("GoogleReCaptcha:SecretKey").Value
                    ))
            {
                TempData["InvalidCredential"] = "Captcha verification failed.";
                return(RedirectToAction("UserLogin", "Account"));
            }

            string ControllerActionName = this.ControllerContext.RouteData.Values["action"].ToString();
            string ControllerName       = this.ControllerContext.RouteData.Values["controller"].ToString();
            Int32? LoginUserID          = HttpContext.Session.GetInt32("UserID");

            string ErrorMessage = string.Empty;

            try
            {
                string pw = SecurityHelperService.Decrypt("8qLsuVEBHnIzavnjCKcC5g==");
                Password = SecurityHelperService.Encrypt(Password);
                UserLoginModel userModel  = _venderRepository.validateUser(Email, Password);
                string         Controller = "";
                string         ActionName = "";
                HttpContext.Session.SetString("Role", "InternalUser");
                if (userModel == null)
                {
                    string strLockRes = _adminRepository.LockedUser(Email);
                    TempData["InvalidCredential"] = strLockRes;
                    //TempData["InvalidCredential"] = "Enter valid credential";
                    return(RedirectToAction("UserLogin", "Account"));
                }
                else
                {
                    var UserID      = Convert.ToInt32(userModel.UserID);
                    var UserName    = userModel.Name;
                    var CompanyId   = userModel.CompanyID;
                    var RoleAccess  = userModel.RoleAccess;
                    var Companyname = userModel.Companyname;

                    Response.Cookies.Delete("RoleAccess");

                    CookieOptions option = new CookieOptions();
                    option.Expires = DateTime.Now.AddDays(2);
                    Response.Cookies.Append("RoleAccess", RoleAccess, option);

                    HttpContext.Session.SetInt32("UserID", UserID);
                    HttpContext.Session.SetString("LoginName", UserName);
                    HttpContext.Session.SetInt32("CompanyID", CompanyId);
                    HttpContext.Session.SetString("RoleAccess", RoleAccess);
                    HttpContext.Session.SetString("Companyname", Companyname);
                    HttpContext.Session.SetString("JWToken", GenerateJWTToken(UserName));

                    if (IsRemember == "1")
                    {
                        SetCookie(UserID.ToString(), UserName, "InternalUser");
                        Response.Cookies.Append("Email", Email, option);
                    }
                    var Res = _CommonRepository.AuditTrailLog("LoginPage", "LoginPage", UserID, 0);
                    if (userModel.IsTemporaryPassword == false)
                    {
                        if (RoleAccess == "Vendor Company")
                        {
                            Controller = "Vendor";
                            ActionName = "VendorDashboardMain";
                        }
                        if (RoleAccess == "Anchor Company")
                        {
                            var    lstchecklimit  = _companyRepository.CheckSetLimit(CompanyId);
                            string PercentageRate = Convert.ToString(lstchecklimit.ElementAt(0).PercentageRate);
                            string PaymentDays    = Convert.ToString(lstchecklimit.ElementAt(0).PaymentDays);
                            //if (PercentageRate != "" && PaymentDays != "")
                            //{
                            Controller = "AnchorCompany";
                            ActionName = "AnchorDashboard";
                            //}
                            //else
                            //{
                            //    //Controller = "AnchorCompany";
                            //    //ActionName = "AnchorDashboard";
                            //    Controller = "AnchorCompany";
                            //    ActionName = "SetLimit";

                            //}
                        }

                        if (RoleAccess == "Both")
                        {
                            Controller = "AnchorCompany";
                            ActionName = "AnchorDashboard";
                        }
                        if (RoleAccess == "Bank")
                        {
                            Controller = "BankCompany";
                            ActionName = "BankDashboard";
                        }
                        return(RedirectToAction(ActionName, Controller));
                    }
                    else
                    {
                        var data = Encoding.UTF8.GetBytes("InternalUser");
                        var Role = Convert.ToBase64String(data);
                        HttpContext.Session.SetString("Email", userModel.Email);
                        Controller = "Common";
                        ActionName = "ChangePassword";
                        SetCookie(UserID.ToString(), UserName, Role);
                        return(RedirectToAction(ActionName, Controller, new { RoleName = Role }));
                    }
                }
            }
            catch (Exception ex)
            {
                var st        = new StackTrace(ex, true);
                var frame     = st.GetFrame(0);
                int ErrorLine = frame.GetFileLineNumber();
                var Result    = _CommonRepository.LogManagement(ControllerName, ControllerActionName, ex.Message, ErrorLine, LoginUserID);
                return(RedirectToAction("ErrorPage", "Common"));
            }
        }