This repository was archived by the owner on Jan 23, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 8
8
using System ;
9
9
using System . Threading . Tasks ;
10
10
using TodoListWebApp . Utils ;
11
+ using Microsoft . IdentityModel . Protocols ;
11
12
12
13
namespace TodoListWebApp
13
14
{
@@ -42,11 +43,19 @@ public void ConfigureAuth(IApplicationBuilder app)
42
43
options . PostLogoutRedirectUri = Configuration . Get ( "AzureAd:PostLogoutRedirectUri" ) ;
43
44
options . Notifications = new OpenIdConnectAuthenticationNotifications
44
45
{
45
- AuthorizationCodeReceived = OnAuthorizationCodeReceived
46
+ AuthorizationCodeReceived = OnAuthorizationCodeReceived ,
47
+ AuthenticationFailed = OnAuthenticationFailed
46
48
} ;
47
49
} ) ;
48
50
}
49
51
52
+ private Task OnAuthenticationFailed ( AuthenticationFailedNotification < OpenIdConnectMessage , OpenIdConnectAuthenticationOptions > notification )
53
+ {
54
+ notification . HandleResponse ( ) ;
55
+ notification . Response . Redirect ( "/Home/Error?message=" + notification . Exception . Message ) ;
56
+ return Task . FromResult ( 0 ) ;
57
+ }
58
+
50
59
public async Task OnAuthorizationCodeReceived ( AuthorizationCodeReceivedNotification notification )
51
60
{
52
61
// Acquire a Token for the Graph API and cache it. In the TodoListController, we'll use the cache to acquire a token to the Todo List API
Original file line number Diff line number Diff line change @@ -26,8 +26,9 @@ public IActionResult Contact()
26
26
return View ( ) ;
27
27
}
28
28
29
- public IActionResult Error ( )
29
+ public IActionResult Error ( string message )
30
30
{
31
+ ViewBag . Message = message ;
31
32
return View ( "~/Views/Shared/Error.cshtml" ) ;
32
33
}
33
34
}
Original file line number Diff line number Diff line change 3
3
}
4
4
5
5
<h1 class =" text-danger" >Error.</h1 >
6
- <h2 class =" text-danger" >An error occurred while processing your request.</h2 >
6
+ <h2 class =" text-danger" >We're having trouble signing you in.</h2 >
7
+
8
+ @ViewBag.Message
You can’t perform that action at this time.
0 commit comments