コード例 #1
0
        public async Task <IActionResult> AuthenticateAsync([FromBody] AuthenticateRequest request)
        {
            var client   = _clientFactory.AccountManagerClient();
            var ip       = ipAddress();
            var response = await client.AuthenticateAsync(new AccountManager.Protos.AuthenticateRequest {
                HashedPassword = request.Password, UserName = request.Username, IpAddress = ip
            });

            if (string.IsNullOrEmpty(response.UserId))
            {
                return(BadRequest(new { message = "Username or password is incorrect" }));
            }

            SetTokenCookie(response.RefreshToken);

            return(Ok(response));
        }