Exemple #1
0
        /// <summary>
        /// Log Out
        /// </summary>
        /// <returns></returns>
        public ActionResult LogOut()
        {
            HttpContext context = System.Web.HttpContext.Current;

            UserAuthenticate.Logout(context);
            return(RedirectToAction("Index", "Account"));
        }
        public ActionResult LogOff()
        {
            TempData.Keep("result");

            //if (UserAuthenticate.IsAuthenticated)
            //    _userService.UserLogOff(UserAuthenticate.LogId);
            UserAuthenticate.Logout(System.Web.HttpContext.Current);
            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult ChangePassword(ChangePasswordViewModel model)
        {
            try
            {
                ViewBag.IsActive = "false";
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }

                model.OldPassword = SecurityHelper.Decrypt(model.OldPassword);
                if (model.OldPassword == model.NewPassword)
                {
                    ModelState.AddModelError("", "Current password and new password cannot be same.");
                    return(View(model));
                }
                UserViewModel userModel = _userService.ChangePassword(model);
                if (!string.IsNullOrWhiteSpace(userModel.Id.ToString()))
                {
                    UserAuthenticate.Logout(System.Web.HttpContext.Current);
                    UserAuthenticate.AddLoginCookie(userModel.FirstName + " " + userModel.LastName, userModel.UserTypeCode, userModel.Id.ToString(),
                                                    userModel.UserTypeName, "false");
                    return(RedirectToAction("Dashboard", "Dashboard", new { data = SecurityHelper.Encrypt(Newtonsoft.Json.JsonConvert.SerializeObject(new Qparams()
                        {
                            LogId = Convert.ToInt64(UserAuthenticate.LogId)
                        })) }));
                }
            }
            catch (CustomException customException)
            {
                ModelState.AddModelError("", customException.Message);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Due to some technical problem this process cannot be completed. Please try after some time.");
            }
            return(View(model));
        }
 public ActionResult Unauthorized()
 {
     UserAuthenticate.Logout(System.Web.HttpContext.Current);
     return(View());
 }