Exemplo n.º 1
0
        public async Task <UserRegisteResp> Registe([FromBody] UserRegisteReq req)
        {
            if (!ModelState.IsValid)
            {
                return new UserRegisteResp()
                       {
                           Ret = (int)ResultTypes.ParaNotMeet, Message = "请检查参数填写是否正确!"
                       }
            }
            ;

            var regRes = await service.RegisteUser(req.value, req.pass_code, req.reg_type, MemberShiper.AppAuthorize);

            if (!regRes.IsSuccess)
            {
                return(regRes.ConvertToResult <UserRegisteResp>());
            }

            var tokenRes = MemberTokenUtil.AppendToken(MemberShiper.AppAuthorize.AppSource, regRes.Data.Id,
                                                       MemberAuthorizeType.User);

            return(tokenRes.IsSuccess ?
                   new UserRegisteResp()
            {
                token = tokenRes.Data, user = regRes.Data
            }
                : tokenRes.ConvertToResult <UserRegisteResp>());
        }
    }
Exemplo n.º 2
0
        private static UserRegLoginResp GenerateUserToken(ResultMo <UserInfoMo> userRes)
        {
            if (!userRes.IsSuccess())
            {
                return(userRes.ConvertToResult <UserRegLoginResp>());
            }

            var tokenRes = MemberTokenUtil.AppendToken(MemberShiper.AppAuthorize.AppSource, userRes.data.Id,
                                                       MemberAuthorizeType.User);

            return(tokenRes.IsSuccess()
                ? new UserRegLoginResp()
            {
                token = tokenRes.data, user = userRes.data
            }
                : tokenRes.ConvertToResult <UserRegLoginResp>());
        }