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 88using System ;
99using System . Threading . Tasks ;
1010using TodoListWebApp . Utils ;
11+ using Microsoft . IdentityModel . Protocols ;
1112
1213namespace TodoListWebApp
1314{
@@ -42,11 +43,19 @@ public void ConfigureAuth(IApplicationBuilder app)
4243 options . PostLogoutRedirectUri = Configuration . Get ( "AzureAd:PostLogoutRedirectUri" ) ;
4344 options . Notifications = new OpenIdConnectAuthenticationNotifications
4445 {
45- AuthorizationCodeReceived = OnAuthorizationCodeReceived
46+ AuthorizationCodeReceived = OnAuthorizationCodeReceived ,
47+ AuthenticationFailed = OnAuthenticationFailed
4648 } ;
4749 } ) ;
4850 }
4951
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+
5059 public async Task OnAuthorizationCodeReceived ( AuthorizationCodeReceivedNotification notification )
5160 {
5261 // 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()
2626 return View ( ) ;
2727 }
2828
29- public IActionResult Error ( )
29+ public IActionResult Error ( string message )
3030 {
31+ ViewBag . Message = message ;
3132 return View ( "~/Views/Shared/Error.cshtml" ) ;
3233 }
3334 }
Original file line number Diff line number Diff line change 33}
44
55<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