예제 #1
0
        public async Task CreateTenantTokenToThisNode(CreateTenantTokenDetails createTenantTokenDetails)
        {
            if (_tenantRepository.GetTenantToken(createTenantTokenDetails.Tenant, createTenantTokenDetails.Token.Token) == null)
            {
                _tenantApiService.AddToken(createTenantTokenDetails.Tenant, createTenantTokenDetails.Token);
            }

            // send to other nodes....
            await _storageHubService.SendCreateTenantTokenStorage(createTenantTokenDetails);
        }
예제 #2
0
        public ActionResult <string> AddTenantToken(string tenantName, [FromBody] DateTime expireDate)
        {
            tenantName = tenantName.ToLower().Replace(" ", string.Empty);

            var isFromCli = HttpContext.Request.Headers["x-called-by"].ToString();

            if (isFromCli != "")
            {
                _logger.LogInformation($"{isFromCli} POST '{HttpContext.Request.Path}' is called");
            }
            else
            {
                _logger.LogInformation($"POST '{HttpContext.Request.Path}' is called");
            }
            var token = _tenantService.AddToken(tenantName, expireDate);

            if (token != null)
            {
                return(Ok($"Token '{token}' has been created for tenant '{tenantName}'"));
            }

            return(BadRequest("Something went wrong, try to create Token one more time"));
        }