Beispiel #1
0
        public ResponseBaseViewModel <string> AutoLogin(ClientInfoRequestViewModel request)
        {
            var cid = this.GetCid();

            if (cid == 0)
            {
                return(new ResponseBaseViewModel <string>
                {
                    Flag = new ResponseCodeViewModel()
                    {
                        Code = -1, Message = "success", MojoryToken = ""
                    }
                });
            }
            var clientId = request.ClientId;
            ICustomerDomainFactory factory = new CustomerDomainFactory();
            var domain = factory.CreateVerifyCustomerDomainObj();

            if (domain.AutoLogin(cid, request.ClientId))
            {
                return(new ResponseBaseViewModel <string>
                {
                    Flag = new ResponseCodeViewModel()
                    {
                        Code = 0, Message = "success", MojoryToken = ""
                    }
                });
            }
            else
            {
                return(new ResponseBaseViewModel <string>
                {
                    Flag = new ResponseCodeViewModel()
                    {
                        Code = -1, Message = "设备ID错误", MojoryToken = ""
                    }
                });
            }
        }
Beispiel #2
0
        public ResponseBaseViewModel <LoginResponseViewModel> MojoryLogin([FromBody] LoginRequestViewModel request)
        {
            string token = this.GetToken();
            ICustomerDomainFactory factory = new CustomerDomainFactory();
            var domain = factory.CreateVerifyCustomerDomainObj();

            CustomerLoginModel loginModel = new CustomerLoginModel
            {
                Password        = request.Password,
                UserId          = request.UserId,
                CorpId          = request.CorpId,
                Token           = token,
                ClientId        = request.ClientId,
                ClientType      = this.GetOrderSource(),
                IsCheckClientId = request.IsCheckClientId
            };
            //为了appstore审核通过

            /*
             * if (request.CorpId.ToLower().Trim() == "mzl")
             * {
             *  loginModel.IsCheckClientId = false;
             * }
             */
            string clientId = request.ClientId;
            ITokenDomainFactory tokenFactory = new TokenDomainFactory();
            var tokenDomain = tokenFactory.CreateDomainObj();

            domain.TokenEvent += tokenDomain.UpdateUserToken;
            CustomerInfoModel customer = domain.DoLogin(loginModel);

            domain.TokenEvent -= tokenDomain.UpdateUserToken;

            ResponseBaseViewModel <LoginResponseViewModel> v = new ResponseBaseViewModel <LoginResponseViewModel> ();

            if (customer == null)
            {
                v.Flag = new ResponseCodeViewModel()
                {
                    Code = -1, Message = "用户名或密码失败"
                }
            }
            ;
            else if (clientId != loginModel.ClientId && !string.IsNullOrWhiteSpace(clientId))
            {
                v.Flag = new ResponseCodeViewModel()
                {
                    Code = -2, Message = "设备ID与原ID不同"
                };
            }
            else
            {
                v.Flag = new ResponseCodeViewModel()
                {
                    Code = 0, Message = "success", MojoryToken = token
                };
                v.Data = new LoginResponseViewModel();
            }

            return(v);
        }