Can you be authorized without being authenticated?

Hi all, I’m working on our companies web application and for this code:

“`c-sharp [Authorize] public class CustomersController {

public ActionResult Index() { if (User.Identity.IsAuthenticated) { // proceed to get view model from database } else { return new HttpNotFoundResult(); } } 

} “`

Is this check for User.Identity.IsAuthenticated redundant if the [Authorize] filter is used on the class (or action)? Bit of a silly question but this code confused me and I need to do some refactoring and worried about removing it. Thanks.

submitted by /u/ShenroEU
[link] [comments]

Leave a Reply