Exemple #1
0
        /// <summary>
        /// 用户退出
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string LogOut(HttpContext context)
        {
            string resultText = "\"ok\":{0},\"msg\":\"{1}\"";
            string resultMsg  = string.Empty;

            try
            {
                T_User user = Static.GetUserForCookie();

                //记录日志
                if (user != null)
                {
                    LogHelper.WriteOperationLog("退出系统", user.LoginName + " 成功退出系统", user.LoginName, Static.GetIPadress());
                }

                //清除当前用户权限Cookie数据
                Static.DeleteUserRightForCache(user);

                //清除当前会话用户数据
                Static.DeleteUserToCookie();

                resultMsg = string.Format(resultText, "0", "成功退出!");
            }
            catch (Exception ex)
            {
                resultMsg = string.Format(resultText, "0", "服务器异常!");
            }
            return("{" + resultMsg + "}");
        }
Exemple #2
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string Pwd(HttpContext context)
        {
            string resultText = "\"ok\":{0},\"msg\":\"{1}\"";
            string resultMsg  = string.Empty;

            string p1 = context.Request["p1"];
            string p2 = context.Request["p2"];
            string p3 = context.Request["p3"];

            if (string.IsNullOrEmpty(p1) || string.IsNullOrEmpty(p2) || string.IsNullOrEmpty(p3))
            {
                resultMsg = string.Format(resultText, -1, "参数不对!");
            }
            else
            {
                //获取当前用户
                T_User user = Static.GetUserForCookie();
                if (user != null)
                {
                    if (user.Pwd == Static.GetEncryptPwd(p1.ToLower(), user.RandKey))
                    {
                        T_User newUser = new T_User()
                        {
                            Id  = user.Id,
                            Pwd = Static.GetEncryptPwd(p2.ToLower(), user.RandKey)
                        };
                        if (userBLL.Update(newUser))
                        {
                            Static.DeleteUserToCookie();
                            resultMsg = string.Format(resultText, 0, "操作成功!");

                            T_Logs log = LogHelper.GetLog();
                            log.LogContext = user.LoginName + " 成功修改密码!";
                            LogHelper.WriteOperationLog(log);
                        }
                        else
                        {
                            resultMsg = string.Format(resultText, -2, "操作失败!");
                        }
                    }
                    else
                    {
                        resultMsg = string.Format(resultText, -3, "原密码不正确!");
                    }
                }
                else
                {
                    resultMsg = string.Format(resultText, -4, "请登录后再进行操作!");
                }
            }
            return("{" + resultMsg + "}");
        }