Beispiel #1
0
        public async Task<NewtonsoftJsonActionResult<ValidateResult<CrmEntity>>> loginphone(UserLoginRequest request)
        {

            UsermessageRequest req = new UsermessageRequest();
            req.phone = request.account;
            req.type = (request.type == "2" ? (int)UserEnum.UserMessEnum.登陆 : (int)UserEnum.UserMessEnum.注册);//
            req.valcode = request.valcode;
            //验证码验证
            ValidateResult res = await _appUsermessage.ValCode(req);
            if (res.Result)
            {

                //验证通过;判断是登陆还是注册,登陆获取用户信息,注册直接返回验证成功
                if (request.type == "2")
                {

                    ValidateResult<CrmEntity> crm = await _appUser.GetUser(request);
                    _appUser.LoginLog(request, crm.Data.Id, (int)UserEnum.LoginlogEnum.成功);
                    return crm;
                }
                else
                {
                    ValidateResult<CrmEntity> ret = new ValidateResult<CrmEntity>();
                    ret.Result = true;
                    res.Description = "验证成功!";
                    return ret;
                }
            }
            else
            {
                //登陆验证失败,写入登陆日志
                if (request.type == "2")
                {
                    ValidateResult<CrmEntity> crm = await _appUser.GetUser(request);
                    _appUser.LoginLog(request, crm.Data.Id, (int)UserEnum.LoginlogEnum.失败);
                }
                ValidateResult<CrmEntity> ret = new ValidateResult<CrmEntity>();
                ret.Result = false;
                ret.Description = res.Description;
                return ret;
            }
        }