예제 #1
0
        public JsonResult UpdatePassword(string newPassword)
        {
            FormsAuthenticationTicket ticket = null;

            try
            {
                bool isSuccess = false;
                _UserDetailsBusinessLogic = new UserDetailsBusinessLogic();

                HttpCookie authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                ticket = FormsAuthentication.Decrypt(authCookie.Value);

                int currentUserId = redirectedUserId == 0?_UserDetailsBusinessLogic.GetUserID(ticket.Name): redirectedUserId;

                //Delete temperory password=>If existing only.
                _UserDetailsBusinessLogic.DeleteTemperoryPassword(currentUserId);

                isSuccess = _UserDetailsBusinessLogic.UpdatePassword(newPassword, currentUserId);

                return(Json(isSuccess));
            }
            catch (Exception ex)
            {
                currentFile = this.ControllerContext.RouteData.Values["controller"].ToString();  // System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                methodName = sf.GetMethod().Name;
                ErrorLogHelper.UpdatingErrorLog(currentFile + "-" + methodName, ticket == null ? "N/A" : ticket.Name, ex);
                return(Json(false));
            }
        }