Skip to content

Commit c739968

Browse files
Merge pull request #102 from StuartFerguson/tasl/#99_roleenvvariables
Minor updates
2 parents ca4bbe9 + d65d5b9 commit c739968

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

EstateManagement/Controllers/EstateController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public async Task<IActionResult> GetEstate([FromRoute] Guid estateId,
118118
// Get the Estate Id claim from the user
119119
Claim estateIdClaim = ClaimsHelper.GetUserClaim(this.User, "EstateId", estateId.ToString());
120120

121-
if (ClaimsHelper.IsUserRolesValid(this.User, new[] {"Estate"}) == false)
121+
String estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName");
122+
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { String.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false)
122123
{
123124
return this.Forbid();
124125
}

EstateManagement/Controllers/MerchantController.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ public async Task<IActionResult> CreateMerchant([FromRoute] Guid estateId,
9393
// Get the Estate Id claim from the user
9494
Claim estateIdClaim = ClaimsHelper.GetUserClaim(this.User, "EstateId", estateId.ToString());
9595

96-
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { "Estate" }) == false)
96+
String estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName");
97+
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { String.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false)
9798
{
9899
return this.Forbid();
99100
}
@@ -150,7 +151,8 @@ public async Task<IActionResult> GetMerchant([FromRoute] Guid estateId, [FromRou
150151
// Get the Estate Id claim from the user
151152
Claim estateIdClaim = ClaimsHelper.GetUserClaim(this.User, "EstateId", estateId.ToString());
152153

153-
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { "Estate" }) == false)
154+
String estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName");
155+
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { String.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false)
154156
{
155157
return this.Forbid();
156158
}
@@ -188,7 +190,8 @@ public async Task<IActionResult> AssignOperator([FromRoute] Guid estateId,
188190
// Get the Estate Id claim from the user
189191
Claim estateIdClaim = ClaimsHelper.GetUserClaim(this.User, "EstateId", estateId.ToString());
190192

191-
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { "Estate" }) == false)
193+
String estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName");
194+
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { String.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false)
192195
{
193196
return this.Forbid();
194197
}
@@ -224,7 +227,8 @@ public async Task<IActionResult> CreateMerchantUser([FromRoute] Guid estateId,
224227
// Get the Estate Id claim from the user
225228
Claim estateIdClaim = ClaimsHelper.GetUserClaim(this.User, "EstateId", estateId.ToString());
226229

227-
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { "Estate" }) == false)
230+
String estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName");
231+
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { String.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false)
228232
{
229233
return this.Forbid();
230234
}
@@ -264,7 +268,8 @@ public async Task<IActionResult> AddDevice([FromRoute] Guid estateId,
264268
// Get the Estate Id claim from the user
265269
Claim estateIdClaim = ClaimsHelper.GetUserClaim(this.User, "EstateId", estateId.ToString());
266270

267-
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { "Estate" }) == false)
271+
String estateRoleName = Environment.GetEnvironmentVariable("EstateRoleName");
272+
if (ClaimsHelper.IsUserRolesValid(this.User, new[] { String.IsNullOrEmpty(estateRoleName) ? "Estate" : estateRoleName }) == false)
268273
{
269274
return this.Forbid();
270275
}

0 commit comments

Comments
 (0)