File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
4-WebApp-your-API/4-1-MyOrg/TodoListService/Controllers Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -120,10 +120,6 @@ public IActionResult Post([FromBody] Todo todo)
120
120
//with such a permission any owner name is accepted from UI
121
121
owner = todo . Owner ;
122
122
}
123
- else
124
- {
125
- throw new ApplicationException ( "Somehow you've sneaked in. Impossible... Just a bug in Matrix..." ) ;
126
- }
127
123
128
124
int id = TodoStore . Values . OrderByDescending ( x => x . Id ) . FirstOrDefault ( ) . Id + 1 ;
129
125
Todo todonew = new Todo ( ) { Id = id , Owner = owner , Title = todo . Title } ;
@@ -168,15 +164,19 @@ public IActionResult Patch(int id, [FromBody] Todo todo)
168
164
//check if the permission is inside claims
169
165
private bool IsInPermissions ( string [ ] permissionsNames )
170
166
{
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 ( ) ?
172
168
. Value . Split ( ' ' ) . Any ( v => permissionsNames . Any ( p => p . Equals ( v ) ) ) ;
169
+
170
+ return result ?? false ;
173
171
}
174
172
175
173
//check if the scope is inside claims
176
174
private bool IsInScopes ( string [ ] scopesNames )
177
175
{
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 ( ) ?
179
177
. Value . Split ( ' ' ) . Any ( v => scopesNames . Any ( s => s . Equals ( v ) ) ) ;
178
+
179
+ return result ?? false ;
180
180
}
181
181
}
182
182
}
You can’t perform that action at this time.
0 commit comments