From 46b00503d22c9a3b946cb7df49de6ae6e4e425b9 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 28 Jul 2010 17:11:41 -0700 Subject: [PATCH] Remove the self-subscription of user accounts from the feed on OrchardProject.net --HG-- branch : dev --- .../Controllers/AccountController.cs | 74 +------------------ .../Controllers/ModulesController.cs | 2 +- ...PackageIndexReferenceImplementation.csproj | 3 - .../Views/Account/ChangePassword.aspx | 52 ------------- .../Views/Account/ChangePasswordSuccess.aspx | 12 --- .../Views/Account/Register.aspx | 60 --------------- .../Web.config | 41 +++------- 7 files changed, 13 insertions(+), 231 deletions(-) delete mode 100644 src/Tools/PackageIndexReferenceImplementation/Views/Account/ChangePassword.aspx delete mode 100644 src/Tools/PackageIndexReferenceImplementation/Views/Account/ChangePasswordSuccess.aspx delete mode 100644 src/Tools/PackageIndexReferenceImplementation/Views/Account/Register.aspx diff --git a/src/Tools/PackageIndexReferenceImplementation/Controllers/AccountController.cs b/src/Tools/PackageIndexReferenceImplementation/Controllers/AccountController.cs index ba502fd47..6cd8c0b65 100644 --- a/src/Tools/PackageIndexReferenceImplementation/Controllers/AccountController.cs +++ b/src/Tools/PackageIndexReferenceImplementation/Controllers/AccountController.cs @@ -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(); - } - } } diff --git a/src/Tools/PackageIndexReferenceImplementation/Controllers/ModulesController.cs b/src/Tools/PackageIndexReferenceImplementation/Controllers/ModulesController.cs index 6f63855c0..d0347d8e9 100644 --- a/src/Tools/PackageIndexReferenceImplementation/Controllers/ModulesController.cs +++ b/src/Tools/PackageIndexReferenceImplementation/Controllers/ModulesController.cs @@ -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."); } diff --git a/src/Tools/PackageIndexReferenceImplementation/PackageIndexReferenceImplementation.csproj b/src/Tools/PackageIndexReferenceImplementation/PackageIndexReferenceImplementation.csproj index 356ba8dd6..fd1a2f903 100644 --- a/src/Tools/PackageIndexReferenceImplementation/PackageIndexReferenceImplementation.csproj +++ b/src/Tools/PackageIndexReferenceImplementation/PackageIndexReferenceImplementation.csproj @@ -112,10 +112,7 @@ - - - diff --git a/src/Tools/PackageIndexReferenceImplementation/Views/Account/ChangePassword.aspx b/src/Tools/PackageIndexReferenceImplementation/Views/Account/ChangePassword.aspx deleted file mode 100644 index a589b8683..000000000 --- a/src/Tools/PackageIndexReferenceImplementation/Views/Account/ChangePassword.aspx +++ /dev/null @@ -1,52 +0,0 @@ -<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> - - - Change Password - - - -

Change Password

-

- Use the form below to change your password. -

-

- New passwords are required to be a minimum of <%: ViewData["PasswordLength"] %> characters in length. -

- - <% using (Html.BeginForm()) { %> - <%: Html.ValidationSummary(true, "Password change was unsuccessful. Please correct the errors and try again.") %> -
-
- Account Information - -
- <%: Html.LabelFor(m => m.OldPassword) %> -
-
- <%: Html.PasswordFor(m => m.OldPassword) %> - <%: Html.ValidationMessageFor(m => m.OldPassword) %> -
- -
- <%: Html.LabelFor(m => m.NewPassword) %> -
-
- <%: Html.PasswordFor(m => m.NewPassword) %> - <%: Html.ValidationMessageFor(m => m.NewPassword) %> -
- -
- <%: Html.LabelFor(m => m.ConfirmPassword) %> -
-
- <%: Html.PasswordFor(m => m.ConfirmPassword) %> - <%: Html.ValidationMessageFor(m => m.ConfirmPassword) %> -
- -

- -

-
-
- <% } %> -
diff --git a/src/Tools/PackageIndexReferenceImplementation/Views/Account/ChangePasswordSuccess.aspx b/src/Tools/PackageIndexReferenceImplementation/Views/Account/ChangePasswordSuccess.aspx deleted file mode 100644 index 04a185395..000000000 --- a/src/Tools/PackageIndexReferenceImplementation/Views/Account/ChangePasswordSuccess.aspx +++ /dev/null @@ -1,12 +0,0 @@ -<%@Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> - - - Change Password - - - -

Change Password

-

- Your password has been changed successfully. -

-
diff --git a/src/Tools/PackageIndexReferenceImplementation/Views/Account/Register.aspx b/src/Tools/PackageIndexReferenceImplementation/Views/Account/Register.aspx deleted file mode 100644 index e0f4f0226..000000000 --- a/src/Tools/PackageIndexReferenceImplementation/Views/Account/Register.aspx +++ /dev/null @@ -1,60 +0,0 @@ -<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> - - - Register - - - -

Create a New Account

-

- Use the form below to create a new account. -

-

- Passwords are required to be a minimum of <%: ViewData["PasswordLength"] %> characters in length. -

- - <% using (Html.BeginForm()) { %> - <%: Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") %> -
-
- Account Information - -
- <%: Html.LabelFor(m => m.UserName) %> -
-
- <%: Html.TextBoxFor(m => m.UserName) %> - <%: Html.ValidationMessageFor(m => m.UserName) %> -
- -
- <%: Html.LabelFor(m => m.Email) %> -
-
- <%: Html.TextBoxFor(m => m.Email) %> - <%: Html.ValidationMessageFor(m => m.Email) %> -
- -
- <%: Html.LabelFor(m => m.Password) %> -
-
- <%: Html.PasswordFor(m => m.Password) %> - <%: Html.ValidationMessageFor(m => m.Password) %> -
- -
- <%: Html.LabelFor(m => m.ConfirmPassword) %> -
-
- <%: Html.PasswordFor(m => m.ConfirmPassword) %> - <%: Html.ValidationMessageFor(m => m.ConfirmPassword) %> -
- -

- -

-
-
- <% } %> -
diff --git a/src/Tools/PackageIndexReferenceImplementation/Web.config b/src/Tools/PackageIndexReferenceImplementation/Web.config index 4bacee924..b7309aae1 100644 --- a/src/Tools/PackageIndexReferenceImplementation/Web.config +++ b/src/Tools/PackageIndexReferenceImplementation/Web.config @@ -6,15 +6,10 @@ --> - - - - + @@ -26,34 +21,15 @@ - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - @@ -77,5 +53,6 @@ +