This repository was archived by the owner on Jan 23, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-17
lines changed
TodoListWebApp/Controllers Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -143,24 +143,22 @@ public async Task<ActionResult> Index(string item)
143143 {
144144 return RedirectToAction ( "Index" ) ;
145145 }
146- else
146+
147+ //
148+ // If the call failed with access denied, then drop the current access token from the cache,
149+ // and show the user an error indicating they might need to sign-in again.
150+ //
151+ if ( response . StatusCode == System . Net . HttpStatusCode . Unauthorized )
147152 {
148- //
149- // If the call failed with access denied, then drop the current access token from the cache,
150- // and show the user an error indicating they might need to sign-in again.
151- //
152- if ( response . StatusCode == System . Net . HttpStatusCode . Unauthorized )
153- {
154- var todoTokens = authContext . TokenCache . ReadItems ( ) . Where ( a => a . Resource == AzureAdOptions . Settings . TodoListResourceId ) ;
155- foreach ( TokenCacheItem tci in todoTokens )
156- authContext . TokenCache . DeleteItem ( tci ) ;
157-
158- ViewBag . ErrorMessage = "UnexpectedError" ;
159- TodoItem newItem = new TodoItem ( ) ;
160- newItem . Title = "(No items in list)" ;
161- itemList . Add ( newItem ) ;
162- return View ( newItem ) ;
163- }
153+ var todoTokens = authContext . TokenCache . ReadItems ( ) . Where ( a => a . Resource == AzureAdOptions . Settings . TodoListResourceId ) ;
154+ foreach ( TokenCacheItem tci in todoTokens )
155+ authContext . TokenCache . DeleteItem ( tci ) ;
156+
157+ ViewBag . ErrorMessage = "UnexpectedError" ;
158+ TodoItem newItem = new TodoItem ( ) ;
159+ newItem . Title = "(No items in list)" ;
160+ itemList . Add ( newItem ) ;
161+ return View ( newItem ) ;
164162 }
165163 }
166164 catch ( Exception ee )
You can’t perform that action at this time.
0 commit comments