public JsonResponse MemberLogin([FromBody] JsonRequest model)
        {
            try
            {
                RegistModel item = model.Data.ToString()?.DeserialObject <RegistModel>();

                if (string.IsNullOrEmpty(item.UserAccount) || string.IsNullOrEmpty(item.UserPassword))
                {
                    return(new JsonResponse {
                        Code = 1, Msg = "参数不合法"
                    });
                }

                var res = BlogHelper.MemberLogin(item.UserAccount, item.UserPassword, "0", UtilConst.GetIP(), "", "");
                if (res != null && res.IsSucceed)
                {
                    res.MemberInfo.UserPassword = "";
                }

                return(new JsonResponse {
                    Code = res.IsSucceed ? 0 : 1, Msg = res.Message, Data = res
                });
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex, "MemberController/RegistItemMember");
                return(new JsonResponse {
                    Code = 1, Msg = "程序好像开小差了" + ex
                });
            }
        }
Beispiel #2
0
        public JsonResponse Login([FromBody] LoginModel model)
        {
            SysLoginUser user = new SysLoginUser {
                IsSucceed = false
            };

            try
            {
                if (string.IsNullOrEmpty(model.Account) || string.IsNullOrEmpty(model.Password) || string.IsNullOrEmpty(model.Code) || string.IsNullOrEmpty(model.CodeKey))
                {
                    return(new JsonResponse {
                        Code = 1, Msg = "参数不完整"
                    });
                }

                var code = CacheHelper.GetCacheItemAndDel(model.CodeKey)?.ToString();
                if (string.IsNullOrEmpty(code) || code != model.Code)
                {
                    return(new JsonResponse {
                        Code = 1, Msg = "验证码错误"
                    });
                }

                user = BlogHelper.EmployeePasswordLogin(model.Account, model.Password, UtilConst.GetIP(), UtilConst.Agent, UtilConst.Dns);
                if (!CJJ.Blog.Apiv2.Models.ConfigUtil.Isdebug)
                {
                    user.DataIsEncrypt = true;
                }
                return(new JsonResponse {
                    Code = user.IsSucceed ? 0 : 1, Data = user
                });
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex, "LoginController/Login错误");
                return(new JsonResponse {
                    Code = 1, Msg = "系统错误" + ex.Message
                });
            }
        }