@@ -58,27 +58,25 @@ public async Task<IActionResult> Index()
58
58
59
59
return View ( itemList ) ;
60
60
}
61
- else
61
+
62
+ //
63
+ // If the call failed with access denied, then drop the current access token from the cache,
64
+ // and show the user an error indicating they might need to sign-in again.
65
+ //
66
+ if ( response . StatusCode == System . Net . HttpStatusCode . Unauthorized )
62
67
{
63
- //
64
- // If the call failed with access denied, then drop the current access token from the cache,
65
- // and show the user an error indicating they might need to sign-in again.
66
- //
67
- if ( response . StatusCode == System . Net . HttpStatusCode . Unauthorized )
68
- {
69
- var todoTokens = authContext . TokenCache . ReadItems ( ) . Where ( a => a . Resource == AzureAdOptions . Settings . TodoListResourceId ) ;
70
- foreach ( TokenCacheItem tci in todoTokens )
71
- authContext . TokenCache . DeleteItem ( tci ) ;
68
+ var todoTokens = authContext . TokenCache . ReadItems ( ) . Where ( a => a . Resource == AzureAdOptions . Settings . TodoListResourceId ) ;
69
+ foreach ( TokenCacheItem tci in todoTokens )
70
+ authContext . TokenCache . DeleteItem ( tci ) ;
72
71
73
- ViewBag . ErrorMessage = "UnexpectedError" ;
74
- TodoItem newItem = new TodoItem ( ) ;
75
- newItem . Title = "(No items in list)" ;
76
- itemList . Add ( newItem ) ;
77
- return View ( itemList ) ;
78
- }
72
+ ViewBag . ErrorMessage = "UnexpectedError" ;
73
+ TodoItem newItem = new TodoItem ( ) ;
74
+ newItem . Title = "(No items in list)" ;
75
+ itemList . Add ( newItem ) ;
76
+ return View ( itemList ) ;
79
77
}
80
78
}
81
- catch ( Exception ee )
79
+ catch ( Exception )
82
80
{
83
81
if ( HttpContext . Request . Query [ "reauth" ] == "True" )
84
82
{
@@ -143,27 +141,25 @@ public async Task<ActionResult> Index(string item)
143
141
{
144
142
return RedirectToAction ( "Index" ) ;
145
143
}
146
- else
144
+
145
+ //
146
+ // If the call failed with access denied, then drop the current access token from the cache,
147
+ // and show the user an error indicating they might need to sign-in again.
148
+ //
149
+ if ( response . StatusCode == System . Net . HttpStatusCode . Unauthorized )
147
150
{
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
- }
151
+ var todoTokens = authContext . TokenCache . ReadItems ( ) . Where ( a => a . Resource == AzureAdOptions . Settings . TodoListResourceId ) ;
152
+ foreach ( TokenCacheItem tci in todoTokens )
153
+ authContext . TokenCache . DeleteItem ( tci ) ;
154
+
155
+ ViewBag . ErrorMessage = "UnexpectedError" ;
156
+ TodoItem newItem = new TodoItem ( ) ;
157
+ newItem . Title = "(No items in list)" ;
158
+ itemList . Add ( newItem ) ;
159
+ return View ( newItem ) ;
164
160
}
165
161
}
166
- catch ( Exception ee )
162
+ catch ( Exception )
167
163
{
168
164
//
169
165
// The user needs to re-authorize. Show them a message to that effect.
0 commit comments