Ejemplo n.º 1
0
        /// <summary>
        /// Logs the in.
        /// </summary>
        /// <returns>ActionResult.</returns>
        public ActionResult LogIn(string returnUrl)
        {
            if (ProjectSession.UserID > 0)
            {
                return(RedirectToAction(Actions.Individual, Pages.Controllers.Master));
            }

            LoginModel loginModel = new LoginModel();

            if (Request.Cookies["TradingLicenseIsRemember"] != null && Request.Cookies["TradingLicenseIsRemember"] != null)
            {
                loginModel.RememberMe = ConvertTo.Boolean(Request.Cookies["TradingLicenseIsRemember"].Value);
                if (loginModel.RememberMe)
                {
                    if (Request.Cookies["TradingLicenseUserName"] != null)
                    {
                        loginModel.Username = Request.Cookies["TradingLicenseUserName"].Value;
                    }

                    if (Request.Cookies["TradingLicensePassword"] != null)
                    {
                        loginModel.Password = EncryptionDecryption.GetDecrypt(Request.Cookies["TradingLicensePassword"].Value);
                    }
                }
            }

            if (TempData["openPopup"] != null)
            {
                ViewBag.openPopup = TempData["openPopup"];
            }

            loginModel.ReturnUrl = returnUrl;
            return(View(loginModel));
        }
Ejemplo n.º 2
0
        public IActionResult KendoRead([DataSourceRequest] DataSourceRequest request)
        {
            try
            {
                if (!request.Sorts.Any())
                {
                    request.Sorts.Add(new SortDescriptor("Name", ListSortDirection.Ascending));
                }

                List <UserModel> result = new List <UserModel>();

                IEnumerable <UserModel> modelResult = _service.GetAll();


                foreach (UserModel entity in modelResult)
                {
                    entity.Password = EncryptionDecryption.GetDecrypt(entity.Password);

                    result.Add(entity);
                }

                return(Json(result.ToDataSourceResult(request)));
            }
            catch (Exception ex)
            {
                return(Json(ex));
            }
        }
Ejemplo n.º 3
0
        public ActionResult ResetPassword(string q)
        {
            Session.Abandon();
            Session.Clear();
            ResetPasswordModel resetPasswordModel = new ResetPasswordModel();

            ViewBag.IsVisible = 0;
            if (!string.IsNullOrEmpty(q))
            {
                try
                {
                    string parameterString = EncryptionDecryption.GetDecrypt(q);
                    var    parameters      = parameterString.Split('#');

                    if (parameters != null && parameters.Count() == 3)
                    {
                        DateTime urlExpiredTime = DateTime.ParseExact(parameters[2], ProjectConfiguration.EmailDateTimeFormat, System.Globalization.CultureInfo.InvariantCulture);
                        int      roleTypeId     = Convert.ToInt32(parameters[0]);
                        int      id             = Convert.ToInt32(parameters[1]);

                        if (DateTime.Now > urlExpiredTime)
                        {
                            ViewBag.openPopup = CommonHelper.ShowAlertMessageToastr(MessageType.danger.ToString(), Messages.ResetPasswordMessage);
                            return(View(Actions.ResetPassword, resetPasswordModel));
                        }

                        using (var ctx = new LicenseApplicationContext())
                        {
                            if (roleTypeId == SystemEnum.RoleType.User.GetHashCode())
                            {
                                var user = ctx.Users.Where(u => u.UsersID == id).FirstOrDefault();
                                resetPasswordModel.RoleTypeId = roleTypeId;
                                if (user != null && user.UsersID > 0)
                                {
                                    ViewBag.IsVisible     = 1;
                                    resetPasswordModel.Id = user.UsersID;
                                }
                                else
                                {
                                    ViewBag.openPopup = CommonHelper.ShowAlertMessageToastr(MessageType.danger.ToString(), Messages.UrlNotExist);
                                    return(View(Actions.ResetPassword, resetPasswordModel));
                                }
                            }
                            else
                            {
                                ViewBag.openPopup = CommonHelper.ShowAlertMessageToastr(MessageType.danger.ToString(), Messages.UrlNotvalid);
                                return(View(Actions.ResetPassword, resetPasswordModel));
                            }
                        }
                    }
                    else
                    {
                        ViewBag.openPopup = CommonHelper.ShowAlertMessageToastr(MessageType.danger.ToString(), Messages.UrlNotvalid);
                        return(View(Actions.ResetPassword, resetPasswordModel));
                    }
                }
                catch (Exception)
                {
                    ViewBag.openPopup = CommonHelper.ShowAlertMessageToastr(MessageType.danger.ToString(), Messages.UrlNotvalid);
                    return(View(Actions.ResetPassword, resetPasswordModel));
                }
            }
            else
            {
                ViewBag.openPopup = CommonHelper.ShowAlertMessageToastr(MessageType.danger.ToString(), Messages.UrlNotvalid);
            }

            return(View(Actions.ResetPassword, resetPasswordModel));
        }