Esempio n. 1
0
        public ExecuteResult Post([FromBody] AgentInfo agent)
        {
            Agency_Member amember  = new Agency_Member(agent);
            bool          randpass = false;

            if (string.IsNullOrEmpty(amember.Password))
            {
                amember.Password = RandomString.BuildAutoRndPwdString();
                randpass         = true;
            }
            var pass = amember.Password;

            amember.Password = amember.Password.ToMd5Password();//保存摘要 非明文

            var res = amember_service.Add(amember);

            //消息处理
            if (res.IsOk)
            {
                res.Msg += ",注册成功";
                if (randpass)
                {
                    res.Data.Password = pass;//返回明文
                    res.Msg          += ",请您收好密码,服务端不保存密码明文";
                }
                else
                {
                    res.Data.Password = "";//返回明文
                    res.Msg          += ",请记住您所设的密码,服务端不保存密码明文";
                }
            }
            return(res);
        }
Esempio n. 2
0
        public ExecuteResult PutNewPwd([FromBody] AgentInfo agent)
        {
            Agency_Member amember = amember_service.Find(agent.Id);

            if (amember == null)
            {
                return(result.SetFail($"未找到此代理会员{agent.Phone}"));
            }
            if (agent.Password.ToMd5Password() != amember.Password)
            {
                return(result.SetFail($"操作密码不正确"));
            }

            bool randpass = false;

            if (string.IsNullOrEmpty(agent.PayPassword))
            {
                amember.Password = RandomString.BuildAutoRndPwdString();
                randpass         = true;
            }
            else
            {
                agent.Password = agent.PayPassword;
            }
            var pass = amember.Password;

            amember.Password = amember.Password.ToMd5Password();
            var res = amember_service.Update(amember);

            //消息处理
            if (res.IsOk)
            {
                if (randpass)
                {
                    res.Msg          += ",重置密码成功";
                    res.Data.Password = pass;//返回明文
                    res.Msg          += ",请您收好您的新密码,服务端不保存密码明文";
                }
                else
                {
                    res.Data.Password = "";//返回明文
                    res.Msg          += ",修改密码成功";
                    res.Msg          += ",请记住您所设的新密码,服务端不保存密码明文";
                }
            }
            return(result.Set(res));
        }
Esempio n. 3
0
        public ExecuteResult Delete([FromBody] AgentInfo agent)
        {
            Agency_Member amember = amember_service.Find(agent.Id);

            if (amember == null)
            {
                return(result.SetFail($"未找到此代理会员{agent.Phone}"));
            }
            if (agent.Password.ToMd5Password() != amember.Password)
            {
                return(result.SetFail($"操作密码不正确"));
            }

            var res = amember_service.Delete(amember);

            return(result.Set(res));
        }
Esempio n. 4
0
        public ExecuteResult Put([FromBody] AgentInfo agent)
        {
            Agency_Member amember = amember_service.Find(agent.Id);

            if (amember == null)
            {
                return(result.SetFail($"未找到此代理会员{agent.Phone}"));
            }
            if (agent.Password.ToMd5Password() != amember.Password)
            {
                return(result.SetFail($"操作密码不正确"));
            }

            Util.CopyAFromB(amember, agent);//更新数据
            var res = amember_service.Update(amember);

            return(result.Set(res));
        }