예제 #1
0
        public IHttpActionResult Login([FromBody] RequestLogin request)
        {
            var userBll     = new UserManage();
            var tokenResult = new TokenResult();
            var isSuccess   = IdentityValid.ValidateSignature(request.Signature, request.TimeStamp, request.Nonce, request.Appid);

            if (isSuccess)
            {
                if (userBll.Login(request.UserName, request.Pwd))
                {
                    tokenResult.token     = IdentityValid.CreateToken(request.UserName, request.Appid);
                    tokenResult.IsSuccess = true;
                }
                else
                {
                    tokenResult.IsSuccess = false;
                    tokenResult.Msg       = "用户密码错误!";
                }
            }
            else
            {
                tokenResult.IsSuccess = false;
                tokenResult.Msg       = "签名验证失败!";
            }
            return(Json(tokenResult));
        }
예제 #2
0
        public IHttpActionResult RegisterOauth([FromBody] RequestRegisterOauth request)
        {
            var tokenResult = new TokenResult();
            var isSuccess   = IdentityValid.ValidateSignature(request.Signature, request.TimeStamp, request.Nonce, request.Appid);

            if (isSuccess)
            {
                var userBll = new UserManage();
                var user    = new User()
                {
                    IsValid    = true,
                    HeadImgUrl = string.Empty,
                    Pwd        = string.Empty,
                    UserName   = request.UserName,
                    Email      = string.Empty
                };
                if (userBll.IsExist(o => o.UserName == request.UserName))
                {
                    tokenResult.IsSuccess = true;
                    tokenResult.token     = IdentityValid.CreateToken(request.UserName, request.Appid);
                    return(Json(tokenResult));
                }
                else
                {
                    tokenResult.IsSuccess = userBll.Save(user);
                    tokenResult.token     = IdentityValid.CreateToken(request.UserName, request.Appid);
                    return(Json(tokenResult));
                }
            }
            else
            {
                return(Json(new ResponseMsg()
                {
                    IsSuccess = false, Msg = "签名验证失败!"
                }));
            }
        }