Example #1
0
        public async Task <IActionResult> ResetPassword(string userId)
        {
            CommonResult result = new CommonResult();

            try
            {
                string where = string.Format("UserId='{0}'", userId);
                UserLogOn userLogOn = userLogOnService.GetWhere(where);
                Random    random    = new Random();
                string    strRandom = random.Next(100000, 999999).ToString(); //生成编号
                userLogOn.UserSecretkey      = MD5Util.GetMD5_16(GuidUtils.NewGuidFormatN()).ToLower();
                userLogOn.UserPassword       = MD5Util.GetMD5_32(DEncrypt.Encrypt(MD5Util.GetMD5_32(strRandom).ToLower(), userLogOn.UserSecretkey).ToLower()).ToLower();
                userLogOn.ChangePasswordDate = DateTime.Now;
                bool bl = await userLogOnService.UpdateAsync(userLogOn, userLogOn.Id);

                if (bl)
                {
                    result.ErrCode = ErrCode.successCode;
                    result.ErrMsg  = strRandom;
                    result.Success = true;
                }
                else
                {
                    result.ErrMsg  = ErrCode.err43002;
                    result.ErrCode = "43002";
                }
            }catch (Exception ex)
            {
                Log4NetHelper.Error("重置密码异常", ex);//错误记录
                result.ErrMsg = ex.Message;
            }
            return(ToJsonContent(result));
        }
Example #2
0
        public IActionResult Logout()
        {
            CommonResult      result            = new CommonResult();
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();

            yuebonCacheHelper.Remove("login_user_" + CurrentUser.UserId);
            yuebonCacheHelper.Remove("User_Function_" + CurrentUser.UserId);
            UserLogOn userLogOn = _userLogOnService.GetWhere("UserId='" + CurrentUser.UserId + "'");

            userLogOn.UserOnLine = false;
            _userLogOnService.Update(userLogOn, userLogOn.Id);
            CurrentUser    = null;
            result.Success = true;
            result.ErrCode = ErrCode.successCode;
            result.ErrMsg  = "成功退出";
            return(ToJsonContent(result));
        }