11using Microsoft . AspNetCore . Mvc ;
22using Microsoft . AspNetCore . Authorization ;
33
4- public class ProfileController : Controller {
4+ public class ProfileController : Controller
5+ {
56 private void doThings ( ) { }
67 private bool isAuthorized ( ) { return false ; }
78
89 // 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+ {
1012 doThings ( ) ;
1113 return View ( ) ;
1214 }
1315
1416 // GOOD: isAuthorized is checked.
15- public ActionResult Delete2 ( int id ) {
16- if ( ! isAuthorized ( ) ) {
17+ public ActionResult Delete2 ( int id )
18+ {
19+ if ( ! isAuthorized ( ) )
20+ {
1721 return null ;
1822 }
1923 doThings ( ) ;
@@ -22,35 +26,42 @@ public ActionResult Delete2(int id) {
2226
2327 // GOOD: The Authorize attribute is used.
2428 [ Authorize ]
25- public ActionResult Delete3 ( int id ) {
29+ public ActionResult Delete3 ( int id )
30+ {
2631 doThings ( ) ;
2732 return View ( ) ;
2833 }
2934
3035}
3136
3237[ Authorize ]
33- public class AuthBaseController : Controller {
38+ public class AuthBaseController : Controller
39+ {
3440 protected void doThings ( ) { }
3541}
3642
37- public class SubController : AuthBaseController {
43+ public class SubController : AuthBaseController
44+ {
3845 // GOOD: The Authorize attribute is used on the base class.
39- public ActionResult Delete4 ( int id ) {
46+ public ActionResult Delete4 ( int id )
47+ {
4048 doThings ( ) ;
4149 return View ( ) ;
4250 }
4351}
4452
4553[ Authorize ]
46- public class AuthBaseGenericController < T > : Controller {
54+ public class AuthBaseGenericController < T > : Controller
55+ {
4756 protected void doThings ( ) { }
4857}
4958
50- public class SubGenericController : AuthBaseGenericController < string > {
59+ public class SubGenericController : AuthBaseGenericController < string >
60+ {
5161 // GOOD: The Authorize attribute is used on the base class.
52- public ActionResult Delete5 ( int id ) {
62+ public ActionResult Delete5 ( int id )
63+ {
5364 doThings ( ) ;
5465 return View ( ) ;
5566 }
56- }
67+ }
0 commit comments