File tree Expand file tree Collapse file tree
src/cloudscribe.SimpleContent.Web/Controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- // Copyright (c) Source Tree Solutions, LLC. All rights reserved.
2- // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3- // Author: Joe Audette
4- // Created: 2016-02-24
5- // Last Modified: 2019-02-17
6- //
7-
8- using cloudscribe . DateTimeUtils ;
1+ using cloudscribe . DateTimeUtils ;
92using cloudscribe . SimpleContent . Models ;
103using cloudscribe . SimpleContent . Models . Versioning ;
114using cloudscribe . SimpleContent . Web . Services ;
@@ -169,12 +162,17 @@ public virtual async Task<IActionResult> Index(
169162 }
170163 // page is not null at this point
171164
172- if ( ( ! string . IsNullOrEmpty ( page . ViewRoles ) ) )
165+ if ( ! string . IsNullOrEmpty ( page . ViewRoles ) )
173166 {
174- if ( ! User . IsInRoles ( page . ViewRoles ) )
167+ if ( ! User . Identity . IsAuthenticated )
175168 {
176- Log . LogWarning ( $ "page { page . Title } is protected by roles that user is not in so returning 404") ;
177- return NotFound ( ) ;
169+ Log . LogWarning ( $ "page { page . Title } is protected and user is not authenticated, returning login page and 302") ;
170+ return View ( "NotFound" , 401 ) ;
171+ }
172+ else if ( ! User . IsInRoles ( page . ViewRoles ) )
173+ {
174+ Log . LogWarning ( $ "page { page . Title } is protected by roles that user is not in so returning 403") ;
175+ return View ( "NotFound" , 403 ) ;
178176 }
179177 }
180178
You can’t perform that action at this time.
0 commit comments