mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Remove the self-subscription of user accounts from the feed on OrchardProject.net
--HG-- branch : dev
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
@@ -15,11 +10,9 @@ namespace PackageIndexReferenceImplementation.Controllers {
|
||||
public class AccountController : Controller {
|
||||
|
||||
public IFormsAuthenticationService FormsService { get; set; }
|
||||
public IMembershipService MembershipService { get; set; }
|
||||
|
||||
protected override void Initialize(RequestContext requestContext) {
|
||||
if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
|
||||
if (MembershipService == null) { MembershipService = new AccountMembershipService(); }
|
||||
|
||||
base.Initialize(requestContext);
|
||||
}
|
||||
@@ -35,7 +28,7 @@ namespace PackageIndexReferenceImplementation.Controllers {
|
||||
[HttpPost]
|
||||
public ActionResult LogOn(LogOnModel model, string returnUrl) {
|
||||
if (ModelState.IsValid) {
|
||||
if (MembershipService.ValidateUser(model.UserName, model.Password)) {
|
||||
if ( FormsAuthentication.Authenticate(model.UserName, model.Password) ) {
|
||||
FormsService.SignIn(model.UserName, model.RememberMe);
|
||||
if (!String.IsNullOrEmpty(returnUrl)) {
|
||||
return Redirect(returnUrl);
|
||||
@@ -63,69 +56,8 @@ namespace PackageIndexReferenceImplementation.Controllers {
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
|
||||
// **************************************
|
||||
// URL: /Account/Register
|
||||
// **************************************
|
||||
|
||||
public ActionResult Register() {
|
||||
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
|
||||
return View();
|
||||
public ActionResult SHA1(string password) {
|
||||
return new ContentResult { Content = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "sha1") };
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Register(RegisterModel model) {
|
||||
if (ModelState.IsValid) {
|
||||
// Attempt to register the user
|
||||
MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email);
|
||||
|
||||
if (createStatus == MembershipCreateStatus.Success) {
|
||||
FormsService.SignIn(model.UserName, false /* createPersistentCookie */);
|
||||
return RedirectToAction("Index", "Home");
|
||||
}
|
||||
else {
|
||||
ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus));
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far, something failed, redisplay form
|
||||
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// **************************************
|
||||
// URL: /Account/ChangePassword
|
||||
// **************************************
|
||||
|
||||
[Authorize]
|
||||
public ActionResult ChangePassword() {
|
||||
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
|
||||
return View();
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost]
|
||||
public ActionResult ChangePassword(ChangePasswordModel model) {
|
||||
if (ModelState.IsValid) {
|
||||
if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword)) {
|
||||
return RedirectToAction("ChangePasswordSuccess");
|
||||
}
|
||||
else {
|
||||
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
// If we got this far, something failed, redisplay form
|
||||
ViewData["PasswordLength"] = MembershipService.MinPasswordLength;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
// **************************************
|
||||
// URL: /Account/ChangePasswordSuccess
|
||||
// **************************************
|
||||
|
||||
public ActionResult ChangePasswordSuccess() {
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ namespace PackageIndexReferenceImplementation.Controllers {
|
||||
var user = Encoding.UTF8.GetString(Convert.FromBase64String(HttpContext.Request.Headers["User"]));
|
||||
var password = Encoding.UTF8.GetString(Convert.FromBase64String(HttpContext.Request.Headers["Password"]));
|
||||
|
||||
if ( !MembershipService.ValidateUser(user, password) ) {
|
||||
if ( !FormsAuthentication.Authenticate(user, password) ) {
|
||||
throw new AuthenticationException("This credentials are not valid fo this action.");
|
||||
}
|
||||
|
||||
|
@@ -112,10 +112,7 @@
|
||||
<Content Include="Scripts\MicrosoftMvcAjax.debug.js" />
|
||||
<Content Include="Scripts\MicrosoftMvcValidation.js" />
|
||||
<Content Include="Scripts\MicrosoftMvcValidation.debug.js" />
|
||||
<Content Include="Views\Account\ChangePassword.aspx" />
|
||||
<Content Include="Views\Account\ChangePasswordSuccess.aspx" />
|
||||
<Content Include="Views\Account\LogOn.aspx" />
|
||||
<Content Include="Views\Account\Register.aspx" />
|
||||
<Content Include="Views\Home\About.aspx" />
|
||||
<Content Include="Views\Home\Index.aspx" />
|
||||
<Content Include="Views\Shared\Error.aspx" />
|
||||
|
@@ -1,52 +0,0 @@
|
||||
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PackageIndexReferenceImplementation.Models.ChangePasswordModel>" %>
|
||||
|
||||
<asp:Content ID="changePasswordTitle" ContentPlaceHolderID="TitleContent" runat="server">
|
||||
Change Password
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="changePasswordContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
<h2>Change Password</h2>
|
||||
<p>
|
||||
Use the form below to change your password.
|
||||
</p>
|
||||
<p>
|
||||
New passwords are required to be a minimum of <%: ViewData["PasswordLength"] %> characters in length.
|
||||
</p>
|
||||
|
||||
<% using (Html.BeginForm()) { %>
|
||||
<%: Html.ValidationSummary(true, "Password change was unsuccessful. Please correct the errors and try again.") %>
|
||||
<div>
|
||||
<fieldset>
|
||||
<legend>Account Information</legend>
|
||||
|
||||
<div class="editor-label">
|
||||
<%: Html.LabelFor(m => m.OldPassword) %>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
<%: Html.PasswordFor(m => m.OldPassword) %>
|
||||
<%: Html.ValidationMessageFor(m => m.OldPassword) %>
|
||||
</div>
|
||||
|
||||
<div class="editor-label">
|
||||
<%: Html.LabelFor(m => m.NewPassword) %>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
<%: Html.PasswordFor(m => m.NewPassword) %>
|
||||
<%: Html.ValidationMessageFor(m => m.NewPassword) %>
|
||||
</div>
|
||||
|
||||
<div class="editor-label">
|
||||
<%: Html.LabelFor(m => m.ConfirmPassword) %>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
<%: Html.PasswordFor(m => m.ConfirmPassword) %>
|
||||
<%: Html.ValidationMessageFor(m => m.ConfirmPassword) %>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<input type="submit" value="Change Password" />
|
||||
</p>
|
||||
</fieldset>
|
||||
</div>
|
||||
<% } %>
|
||||
</asp:Content>
|
@@ -1,12 +0,0 @@
|
||||
<%@Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
|
||||
|
||||
<asp:Content ID="changePasswordTitle" ContentPlaceHolderID="TitleContent" runat="server">
|
||||
Change Password
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="changePasswordSuccessContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
<h2>Change Password</h2>
|
||||
<p>
|
||||
Your password has been changed successfully.
|
||||
</p>
|
||||
</asp:Content>
|
@@ -1,60 +0,0 @@
|
||||
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PackageIndexReferenceImplementation.Models.RegisterModel>" %>
|
||||
|
||||
<asp:Content ID="registerTitle" ContentPlaceHolderID="TitleContent" runat="server">
|
||||
Register
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="registerContent" ContentPlaceHolderID="MainContent" runat="server">
|
||||
<h2>Create a New Account</h2>
|
||||
<p>
|
||||
Use the form below to create a new account.
|
||||
</p>
|
||||
<p>
|
||||
Passwords are required to be a minimum of <%: ViewData["PasswordLength"] %> characters in length.
|
||||
</p>
|
||||
|
||||
<% using (Html.BeginForm()) { %>
|
||||
<%: Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") %>
|
||||
<div>
|
||||
<fieldset>
|
||||
<legend>Account Information</legend>
|
||||
|
||||
<div class="editor-label">
|
||||
<%: Html.LabelFor(m => m.UserName) %>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
<%: Html.TextBoxFor(m => m.UserName) %>
|
||||
<%: Html.ValidationMessageFor(m => m.UserName) %>
|
||||
</div>
|
||||
|
||||
<div class="editor-label">
|
||||
<%: Html.LabelFor(m => m.Email) %>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
<%: Html.TextBoxFor(m => m.Email) %>
|
||||
<%: Html.ValidationMessageFor(m => m.Email) %>
|
||||
</div>
|
||||
|
||||
<div class="editor-label">
|
||||
<%: Html.LabelFor(m => m.Password) %>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
<%: Html.PasswordFor(m => m.Password) %>
|
||||
<%: Html.ValidationMessageFor(m => m.Password) %>
|
||||
</div>
|
||||
|
||||
<div class="editor-label">
|
||||
<%: Html.LabelFor(m => m.ConfirmPassword) %>
|
||||
</div>
|
||||
<div class="editor-field">
|
||||
<%: Html.PasswordFor(m => m.ConfirmPassword) %>
|
||||
<%: Html.ValidationMessageFor(m => m.ConfirmPassword) %>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<input type="submit" value="Register" />
|
||||
</p>
|
||||
</fieldset>
|
||||
</div>
|
||||
<% } %>
|
||||
</asp:Content>
|
@@ -6,15 +6,10 @@
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<connectionStrings>
|
||||
<add name="ApplicationServices"
|
||||
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"
|
||||
providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
|
||||
<appSettings>
|
||||
<add key="Title" value="Orchard Modules Gallery"/>
|
||||
</appSettings>
|
||||
|
||||
<system.web>
|
||||
|
||||
<compilation debug="true" targetFramework="4.0">
|
||||
@@ -26,34 +21,15 @@
|
||||
</compilation>
|
||||
|
||||
<authentication mode="Forms">
|
||||
<forms loginUrl="~/Account/LogOn" timeout="2880" />
|
||||
<forms loginUrl="~/Account/LogOn" timeout="2880">
|
||||
<credentials passwordFormat="SHA1">
|
||||
<user name="UserName1" password="SHA1EncryptedPassword1"/>
|
||||
<user name="UserName2" password="SHA1EncryptedPassword2"/>
|
||||
<user name="UserName3" password="SHA1EncryptedPassword3"/>
|
||||
</credentials>
|
||||
</forms>
|
||||
</authentication>
|
||||
|
||||
<membership>
|
||||
<providers>
|
||||
<clear/>
|
||||
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
|
||||
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
|
||||
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
|
||||
applicationName="/" />
|
||||
</providers>
|
||||
</membership>
|
||||
|
||||
<profile>
|
||||
<providers>
|
||||
<clear/>
|
||||
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
|
||||
</providers>
|
||||
</profile>
|
||||
|
||||
<roleManager enabled="false">
|
||||
<providers>
|
||||
<clear/>
|
||||
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
|
||||
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
|
||||
</providers>
|
||||
</roleManager>
|
||||
|
||||
<pages>
|
||||
<namespaces>
|
||||
<add namespace="System.Web.Mvc" />
|
||||
@@ -77,5 +53,6 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
</configuration>
|
||||
|
||||
|
Reference in New Issue
Block a user