1
1
using Microsoft . AspNetCore . Mvc ;
2
2
using Microsoft . AspNetCore . Authorization ;
3
3
4
- public class ProfileController : Controller {
4
+ public class ProfileController : Controller
5
+ {
5
6
private void doThings ( ) { }
6
7
private bool isAuthorized ( ) { return false ; }
7
8
8
9
// BAD: This is a Delete method, but no auth is specified.
9
- public ActionResult Delete1 ( int id ) {
10
+ public ActionResult Delete1 ( int id ) // $ Alert
11
+ {
10
12
doThings ( ) ;
11
13
return View ( ) ;
12
14
}
13
15
14
16
// GOOD: isAuthorized is checked.
15
- public ActionResult Delete2 ( int id ) {
16
- if ( ! isAuthorized ( ) ) {
17
+ public ActionResult Delete2 ( int id )
18
+ {
19
+ if ( ! isAuthorized ( ) )
20
+ {
17
21
return null ;
18
22
}
19
23
doThings ( ) ;
@@ -22,35 +26,42 @@ public ActionResult Delete2(int id) {
22
26
23
27
// GOOD: The Authorize attribute is used.
24
28
[ Authorize ]
25
- public ActionResult Delete3 ( int id ) {
29
+ public ActionResult Delete3 ( int id )
30
+ {
26
31
doThings ( ) ;
27
32
return View ( ) ;
28
33
}
29
34
30
35
}
31
36
32
37
[ Authorize ]
33
- public class AuthBaseController : Controller {
38
+ public class AuthBaseController : Controller
39
+ {
34
40
protected void doThings ( ) { }
35
41
}
36
42
37
- public class SubController : AuthBaseController {
43
+ public class SubController : AuthBaseController
44
+ {
38
45
// GOOD: The Authorize attribute is used on the base class.
39
- public ActionResult Delete4 ( int id ) {
46
+ public ActionResult Delete4 ( int id )
47
+ {
40
48
doThings ( ) ;
41
49
return View ( ) ;
42
50
}
43
51
}
44
52
45
53
[ Authorize ]
46
- public class AuthBaseGenericController < T > : Controller {
54
+ public class AuthBaseGenericController < T > : Controller
55
+ {
47
56
protected void doThings ( ) { }
48
57
}
49
58
50
- public class SubGenericController : AuthBaseGenericController < string > {
59
+ public class SubGenericController : AuthBaseGenericController < string >
60
+ {
51
61
// GOOD: The Authorize attribute is used on the base class.
52
- public ActionResult Delete5 ( int id ) {
62
+ public ActionResult Delete5 ( int id )
63
+ {
53
64
doThings ( ) ;
54
65
return View ( ) ;
55
66
}
56
- }
67
+ }
0 commit comments