Skip to content

Commit 3d28001

Browse files
committed
Adding support for getting sites from remote websites.
1 parent 6a872c4 commit 3d28001

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

eFormAPI/eFormAPI/Controllers/SitesController.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using eFormApi.BasePn.Infrastructure;
99
using eFormApi.BasePn.Infrastructure.Helpers;
1010
using eFormApi.BasePn.Infrastructure.Models.API;
11+
using System.Web.Http.Cors;
12+
using eFormAPI.Web.Infrastructure.Helpers.ExchangeTokenValidation;
1113

1214
namespace eFormAPI.Web.Controllers
1315
{
@@ -25,6 +27,28 @@ public OperationDataResult<List<SiteName_Dto>> Index()
2527
return new OperationDataResult<List<SiteName_Dto>>(true, siteNamesDto);
2628
}
2729

30+
[HttpGet]
31+
[AllowAnonymous]
32+
[Route("api/sites/index/exchange/")]
33+
[EnableCors(origins: "*", headers: "content-type", methods: "GET")]
34+
public OperationDataResult<List<SiteName_Dto>> IndexExternally(string token, string callerURL)
35+
{
36+
ExchangeIdToken idToken = new ExchangeIdToken(token);
37+
IdTokenValidationResult result = idToken.Validate(callerURL);
38+
if (result.IsValid)
39+
{
40+
Core core = _coreHelper.GetCore();
41+
var siteNamesDto = core.Advanced_SiteItemReadAll(false);
42+
43+
return new OperationDataResult<List<SiteName_Dto>>(true, siteNamesDto);
44+
}
45+
else
46+
{
47+
return new OperationDataResult<List<SiteName_Dto>> (false,
48+
LocaleHelper.GetString("ErrorWhileObtainSiteList"));
49+
}
50+
}
51+
2852
[HttpGet]
2953
public OperationDataResult<SiteName_Dto> Edit(int id)
3054
{

0 commit comments

Comments
 (0)