Esempio n. 1
0
        public async Task <ActionResult> RequestTokenV2([FromBody] TokenRequest request)
        {
            var data = await _tokenService.Get(request.Account, request.Password);

            //验证不通过
            if (!data)
            {
                return(Unauthorized("Could not verify username and password"));
            }

            var token = GeneralToken.TokenHandle.CreateToken(_configuration, request);

            if (await _tokenService.AddTokenRecordAsync(request.Account, token))
            {
                return(Ok(new
                {
                    token = token
                }));
            }
            throw new MyException("记录token 失败");
        }