Skip to content

Commit 3b794e6

Browse files
committed
update
1 parent 7289a0d commit 3b794e6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

4-WebApp-your-API/4-1-MyOrg/TodoListService/Controllers/TodoListController.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ public IActionResult Post([FromBody] Todo todo)
120120
//with such a permission any owner name is accepted from UI
121121
owner = todo.Owner;
122122
}
123-
else
124-
{
125-
throw new ApplicationException("Somehow you've sneaked in. Impossible... Just a bug in Matrix...");
126-
}
127123

128124
int id = TodoStore.Values.OrderByDescending(x => x.Id).FirstOrDefault().Id + 1;
129125
Todo todonew = new Todo() { Id = id, Owner = owner, Title = todo.Title };
@@ -168,15 +164,19 @@ public IActionResult Patch(int id, [FromBody] Todo todo)
168164
//check if the permission is inside claims
169165
private bool IsInPermissions(string[] permissionsNames)
170166
{
171-
return User.Claims.Where(c => c.Type.Equals(ClaimTypes.Role)).FirstOrDefault()
167+
var result = User.Claims.Where(c => c.Type.Equals(ClaimTypes.Role)).FirstOrDefault()?
172168
.Value.Split(' ').Any(v => permissionsNames.Any(p => p.Equals(v)));
169+
170+
return result ?? false;
173171
}
174172

175173
//check if the scope is inside claims
176174
private bool IsInScopes(string[] scopesNames)
177175
{
178-
return User.Claims.Where(c => c.Type.Equals(Constants.ScopeClaimType)).FirstOrDefault()
176+
var result = User.Claims.Where(c => c.Type.Equals(Constants.ScopeClaimType)).FirstOrDefault()?
179177
.Value.Split(' ').Any(v => scopesNames.Any(s => s.Equals(v)));
178+
179+
return result ?? false;
180180
}
181181
}
182182
}

0 commit comments

Comments
 (0)