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 . Services ;
@@ -174,12 +167,17 @@ public virtual async Task<IActionResult> Index(
174167 }
175168 // page is not null at this point
176169
177- if ( ( ! string . IsNullOrEmpty ( page . ViewRoles ) ) )
170+ if ( ! string . IsNullOrEmpty ( page . ViewRoles ) )
178171 {
179- if ( ! User . IsInRoles ( page . ViewRoles ) )
172+ if ( ! User . Identity . IsAuthenticated )
180173 {
181- Log . LogWarning ( $ "page { page . Title } is protected by roles that user is not in so returning 404") ;
182- return NotFound ( ) ;
174+ Log . LogWarning ( $ "page { page . Title } is protected and user is not authenticated, returning login page and 302") ;
175+ return View ( "NotFound" , 401 ) ;
176+ }
177+ else if ( ! User . IsInRoles ( page . ViewRoles ) )
178+ {
179+ Log . LogWarning ( $ "page { page . Title } is protected by roles that user is not in so returning 403") ;
180+ return View ( "NotFound" , 403 ) ;
183181 }
184182 }
185183
You can’t perform that action at this time.
0 commit comments