();
}
@@ -73,7 +75,19 @@ namespace MicroserviceDemo.AuthServer
app.UseStaticFiles();
app.UseVirtualFiles();
- app.UseMvcWithDefaultRoute();
+ app.UseAuthentication();
+
+ app.UseMvc(routes =>
+ {
+ //TODO: Can we make an extension method for adding these two routes inside the framework?
+ routes.MapRoute(
+ name: "defaultWithArea",
+ template: "{area}/{controller=Home}/{action=Index}/{id?}");
+
+ routes.MapRoute(
+ name: "default",
+ template: "{controller=Home}/{action=Index}/{id?}");
+ });
}
private static IConfigurationRoot BuildConfiguration(IHostingEnvironment env)
diff --git a/src/MicroserviceDemo/MicroserviceDemo.AuthServer/Pages/Index.cshtml b/src/MicroserviceDemo/MicroserviceDemo.AuthServer/Pages/Index.cshtml
new file mode 100644
index 0000000000..0712e36914
--- /dev/null
+++ b/src/MicroserviceDemo/MicroserviceDemo.AuthServer/Pages/Index.cshtml
@@ -0,0 +1,20 @@
+@page
+@model MicroserviceDemo.AuthServer.Pages.IndexModel
+
+Welcome to the Authentication Server!
+
+
+
+
+ Login
+
+ @if (User.Identity.IsAuthenticated)
+ {
+ foreach (var claim in User.Claims)
+ {
+ @claim.Type = @claim.Value
+ }
+ }
+
+
+
\ No newline at end of file
diff --git a/src/MicroserviceDemo/MicroserviceDemo.AuthServer/Pages/Index.cshtml.cs b/src/MicroserviceDemo/MicroserviceDemo.AuthServer/Pages/Index.cshtml.cs
new file mode 100644
index 0000000000..0771c699c0
--- /dev/null
+++ b/src/MicroserviceDemo/MicroserviceDemo.AuthServer/Pages/Index.cshtml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+
+namespace MicroserviceDemo.AuthServer.Pages
+{
+ public class IndexModel : PageModel
+ {
+ public void OnGet()
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/MicroserviceDemo/MicroserviceDemo.Web/MicroservicesDemoWebModule.cs b/src/MicroserviceDemo/MicroserviceDemo.Web/MicroservicesDemoWebModule.cs
index 7b91f3de5a..e2cc2c8ca3 100644
--- a/src/MicroserviceDemo/MicroserviceDemo.Web/MicroservicesDemoWebModule.cs
+++ b/src/MicroserviceDemo/MicroserviceDemo.Web/MicroservicesDemoWebModule.cs
@@ -109,7 +109,16 @@ namespace MicroserviceDemo.Web
app.UseAuthentication();
- app.UseMvcWithDefaultRoute();
+ app.UseMvc(routes =>
+ {
+ routes.MapRoute(
+ name: "defaultWithArea",
+ template: "{area}/{controller=Home}/{action=Index}/{id?}");
+
+ routes.MapRoute(
+ name: "default",
+ template: "{controller=Home}/{action=Index}/{id?}");
+ });
}
private static IConfigurationRoot BuildConfiguration(IHostingEnvironment env)
diff --git a/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Login.cshtml b/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Login.cshtml
index 75cef4ee5e..7e45ba5176 100644
--- a/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Login.cshtml
+++ b/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Login.cshtml
@@ -26,7 +26,7 @@
-
+ @* TODO: Only show if identity server is used *@
diff --git a/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Login.cshtml.cs b/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Login.cshtml.cs
index e71030e3b8..e280fcd7ce 100644
--- a/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Login.cshtml.cs
+++ b/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/Login.cshtml.cs
@@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
+using IdentityServer4.Models;
using IdentityServer4.Services;
using IdentityServer4.Stores;
using Microsoft.AspNetCore.Authentication;
@@ -112,8 +113,20 @@ namespace Volo.Abp.Account.Web.Pages.Account
}
[UnitOfWork] //TODO: Will be removed when we implement action filter
- public virtual async Task OnPostAsync()
+ public virtual async Task OnPostAsync(string action)
{
+ if (action == "Cancel")
+ {
+ var context = await _interaction.GetAuthorizationContextAsync(ReturnUrl);
+ if (context == null)
+ {
+ return RedirectSafely("~/");
+ }
+
+ await _interaction.GrantConsentAsync(context, ConsentResponse.Denied);
+ return RedirectSafely(ReturnUrl);
+ }
+
ValidateModel();
var result = await _signInManager.PasswordSignInAsync(
@@ -128,6 +141,8 @@ namespace Volo.Abp.Account.Web.Pages.Account
throw new UserFriendlyException("Login failed!"); //TODO: Handle other cases, do not throw exception
}
+ //var user = _userManager.FindByIdAsync(result.)
+
return RedirectSafely(ReturnUrl, ReturnUrlHash);
}