BMC: Add Validate_Tenancy End point

This commit is contained in:
Palash Biswas 2022-10-17 21:22:26 +05:30
parent abb01d3318
commit 94699dd23d
2 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BCS.BMC.CompanyMasters.Dto
{
public class GetUrlDto
{
public string InputUrl { get; set; }
}
}

View File

@ -17,6 +17,14 @@ using BCS.BMC.Authorization;
using BCS.BMC.Authorization.Users; using BCS.BMC.Authorization.Users;
using BCS.BMC.Models.TokenAuth; using BCS.BMC.Models.TokenAuth;
using BCS.BMC.MultiTenancy; using BCS.BMC.MultiTenancy;
//using System.Web.Mvc;
using BCS.BMC.CompanyMasters.Dto;
using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using BCS.BMC.BMC.CompanyMasters;
using Abp.Domain.Repositories;
namespace BCS.BMC.Controllers namespace BCS.BMC.Controllers
{ {
@ -30,6 +38,7 @@ namespace BCS.BMC.Controllers
private readonly IExternalAuthConfiguration _externalAuthConfiguration; private readonly IExternalAuthConfiguration _externalAuthConfiguration;
private readonly IExternalAuthManager _externalAuthManager; private readonly IExternalAuthManager _externalAuthManager;
private readonly UserRegistrationManager _userRegistrationManager; private readonly UserRegistrationManager _userRegistrationManager;
private readonly IRepository<CompanyMaster, int> _companyMaster;
public TokenAuthController( public TokenAuthController(
LogInManager logInManager, LogInManager logInManager,
@ -38,7 +47,8 @@ namespace BCS.BMC.Controllers
TokenAuthConfiguration configuration, TokenAuthConfiguration configuration,
IExternalAuthConfiguration externalAuthConfiguration, IExternalAuthConfiguration externalAuthConfiguration,
IExternalAuthManager externalAuthManager, IExternalAuthManager externalAuthManager,
UserRegistrationManager userRegistrationManager) UserRegistrationManager userRegistrationManager,
IRepository<CompanyMaster, int> companyMaster)
{ {
_logInManager = logInManager; _logInManager = logInManager;
_tenantCache = tenantCache; _tenantCache = tenantCache;
@ -47,6 +57,7 @@ namespace BCS.BMC.Controllers
_externalAuthConfiguration = externalAuthConfiguration; _externalAuthConfiguration = externalAuthConfiguration;
_externalAuthManager = externalAuthManager; _externalAuthManager = externalAuthManager;
_userRegistrationManager = userRegistrationManager; _userRegistrationManager = userRegistrationManager;
_companyMaster = companyMaster;
} }
[HttpPost] [HttpPost]
@ -232,5 +243,20 @@ namespace BCS.BMC.Controllers
{ {
return SimpleStringCipher.Instance.Encrypt(accessToken); return SimpleStringCipher.Instance.Encrypt(accessToken);
} }
[HttpGet]
public async Task<ActionResult> ValidateTenancy(GetUrlDto input)
{
if (input.InputUrl == null)
{
return BadRequest();
}
var company = await _companyMaster.FirstOrDefaultAsync(x => x.Url == input.InputUrl.ToString());
if (company == null)
{
return BadRequest();
}
return Ok();
}
} }
} }