mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
Converting the LogOn view to a shape, and adding a ShapeResult to render shapes as an ActionResult without the need of a dedicated view
Work Item: 17046 --HG-- branch : 1.x
This commit is contained in:
@@ -371,6 +371,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Containers\Views\Parts.Container.Contained.SummaryAdmin.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Shapes\Views\ShapeResult\Display.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -0,0 +1 @@
|
||||
@Display(Model)
|
@@ -5,11 +5,11 @@ using System.Security.Principal;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Security;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Security;
|
||||
using Orchard.Themes;
|
||||
using Orchard.Users.Services;
|
||||
using Orchard.Users.ViewModels;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Users.Models;
|
||||
using Orchard.UI.Notify;
|
||||
@@ -44,7 +44,8 @@ namespace Orchard.Users.Controllers {
|
||||
|
||||
if (currentUser == null) {
|
||||
Logger.Information("Access denied to anonymous request on {0}", returnUrl);
|
||||
return View("LogOn", new LogOnViewModel {Title = "Access Denied"});
|
||||
var shape = _orchardServices.New.LogOn().Title(T("Access Denied").Text);
|
||||
return new ShapeResult(shape);
|
||||
}
|
||||
|
||||
//TODO: (erikpo) Add a setting for whether or not to log access denieds since these can fill up a database pretty fast from bots on a high traffic site
|
||||
@@ -57,7 +58,8 @@ namespace Orchard.Users.Controllers {
|
||||
if (_authenticationService.GetAuthenticatedUser() != null)
|
||||
return Redirect("~/");
|
||||
|
||||
return View(new LogOnViewModel { Title = T("Log On").Text });
|
||||
var shape = _orchardServices.New.LogOn().Title(T("Log On").Text);
|
||||
return new ShapeResult(shape);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -66,7 +68,8 @@ namespace Orchard.Users.Controllers {
|
||||
public ActionResult LogOn(string userNameOrEmail, string password, string returnUrl) {
|
||||
var user = ValidateLogOn(userNameOrEmail, password);
|
||||
if (!ModelState.IsValid) {
|
||||
return View(new LogOnViewModel { Title = T("Log On").Text });
|
||||
var shape = _orchardServices.New.LogOn().Title(T("Log On").Text);
|
||||
return new ShapeResult(shape);
|
||||
}
|
||||
|
||||
_authenticationService.SignIn(user, false);
|
||||
|
@@ -75,7 +75,6 @@
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Services\MissingSettingsBanner.cs" />
|
||||
<Compile Include="Services\UserService.cs" />
|
||||
<Compile Include="ViewModels\LogOnViewModel.cs" />
|
||||
<Compile Include="ViewModels\UserCreateViewModel.cs" />
|
||||
<Compile Include="ViewModels\UserEditViewModel.cs" />
|
||||
<Compile Include="ViewModels\UsersIndexViewModel.cs" />
|
||||
@@ -90,7 +89,6 @@
|
||||
<Content Include="Views\Account\ChallengeEmailSuccess.cshtml" />
|
||||
<Content Include="Views\Account\ChallengeEmailSent.cshtml" />
|
||||
<Content Include="Views\Account\ChallengeEmailFail.cshtml" />
|
||||
<Content Include="Views\Account\LogOn.cshtml" />
|
||||
<Content Include="Views\Account\Register.cshtml" />
|
||||
<Content Include="Views\Admin\Edit.cshtml" />
|
||||
<Content Include="Views\Admin\Create.cshtml" />
|
||||
@@ -129,6 +127,9 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Views\Account\LostPassword.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Views\LogOn.cshtml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
@@ -1,5 +0,0 @@
|
||||
namespace Orchard.Users.ViewModels {
|
||||
public class LogOnViewModel {
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
@@ -1,12 +1,11 @@
|
||||
@model Orchard.Users.ViewModels.LogOnViewModel
|
||||
@using Orchard.ContentManagement;
|
||||
@using Orchard.ContentManagement;
|
||||
|
||||
@{
|
||||
var userCanRegister = @WorkContext.CurrentSite.As<Orchard.Users.Models.RegistrationSettingsPart>().UsersCanRegister;
|
||||
var enableLostPassword = @WorkContext.CurrentSite.As<Orchard.Users.Models.RegistrationSettingsPart>().EnableLostPassword;
|
||||
}
|
||||
|
||||
<h1 class="page-title">@Html.TitleForPage(Model.Title)</h1>
|
||||
<h1 class="page-title">@Html.TitleForPage((string)Model.Title)</h1>
|
||||
<p>
|
||||
@T("Please enter your username and password.")
|
||||
@if(userCanRegister) { @Html.ActionLink(T("Register").Text, "Register") @T(" if you don't have an account.") }
|
10
src/Orchard/Mvc/ShapeResult.cs
Normal file
10
src/Orchard/Mvc/ShapeResult.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Mvc {
|
||||
public class ShapeResult : ViewResult {
|
||||
public ShapeResult(dynamic shape) {
|
||||
ViewData.Model = shape;
|
||||
ViewName = "~/Core/Shapes/Views/ShapeResult/Display.cshtml";
|
||||
}
|
||||
}
|
||||
}
|
@@ -181,6 +181,7 @@
|
||||
<Compile Include="Messaging\Services\DefaultMessageManager.cs" />
|
||||
<Compile Include="Mvc\Extensions\ControllerExtensions.cs" />
|
||||
<Compile Include="Mvc\IOrchardViewPage.cs" />
|
||||
<Compile Include="Mvc\ShapeResult.cs" />
|
||||
<Compile Include="Mvc\Spooling\HtmlStringWriter.cs" />
|
||||
<Compile Include="Mvc\ViewEngines\Razor\IRazorCompilationEvents.cs" />
|
||||
<Compile Include="Security\IEncryptionService.cs" />
|
||||
|
Reference in New Issue
Block a user