From af68bc2110c9adfb7a932fd5215df6dc361996ea Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 15 Nov 2019 14:30:19 +0800 Subject: [PATCH] Implement external login only. --- .../Account/IdentityServerSupportedLoginModel.cs | 11 ++++++----- .../Areas/Account/Controllers/LogoutController.cs | 7 ++++++- .../Pages/Account/Login.cshtml.cs | 4 +++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs index b6902e86d8..0714d5b323 100644 --- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs +++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs @@ -1,4 +1,4 @@ -using IdentityModel; +using IdentityModel; using IdentityServer4.Events; using IdentityServer4.Models; using IdentityServer4.Services; @@ -40,7 +40,7 @@ namespace Volo.Abp.Account.Web.Pages.Account IdentityServerEvents = identityServerEvents; } - public override async Task OnGetAsync() + public override async Task OnGetAsync() { LoginInput = new LoginInputModel(); @@ -63,7 +63,7 @@ namespace Volo.Abp.Account.Web.Pages.Account { LoginInput.UserNameOrEmailAddress = context.LoginHint; ExternalProviders = new[] { new ExternalProviderModel { AuthenticationScheme = context.IdP } }; - return; + return Page(); } var schemes = await _schemeProvider.GetAllSchemesAsync(); @@ -96,9 +96,10 @@ namespace Volo.Abp.Account.Web.Pages.Account if (IsExternalLoginOnly) { - //return await ExternalLogin(vm.ExternalLoginScheme, returnUrl); - throw new NotImplementedException(); + return await base.OnPostExternalLogin(providers.First().AuthenticationScheme); } + + return Page(); } [UnitOfWork] //TODO: Will be removed when we implement action filter diff --git a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs index 1f1b43b853..eb7d1cbc84 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Areas/Account/Controllers/LogoutController.cs @@ -17,10 +17,15 @@ namespace Volo.Abp.Account.Web.Areas.Account.Controllers } //todo@alper: this method can be moved to AccountController like "account/logout" - public async Task Index() + public async Task Index(string returnUrl = null) { await _signInManager.SignOutAsync(); + if (returnUrl != null) + { + return LocalRedirect(returnUrl); + } + return RedirectToPage("/Account/Login"); } } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs index cc82de414f..74691dba33 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml.cs @@ -56,7 +56,7 @@ namespace Volo.Abp.Account.Web.Pages.Account _accountOptions = accountOptions.Value; } - public virtual async Task OnGetAsync() + public virtual async Task OnGetAsync() { LoginInput = new LoginInputModel(); @@ -80,6 +80,8 @@ namespace Volo.Abp.Account.Web.Pages.Account //return await ExternalLogin(vm.ExternalLoginScheme, returnUrl); throw new NotImplementedException(); } + + return Page(); } [UnitOfWork] //TODO: Will be removed when we implement action filter