# HG changeset patch # User Nelo@Guinea.neluz.int # Date 1312169284 10800 # Node ID 62dc9fb3a03e418ce8887490ebcf9629b802e11a # Parent a5ff4de4a1d38e3739dc26b8d3473e5d97c39d76 Quitando cuentas BuiltIn diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Domain/Patrocinador.cs --- a/Agendas/trunk/src/Agendas.Domain/Patrocinador.cs Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Patrocinador.cs Mon Aug 01 00:28:04 2011 -0300 @@ -1,7 +1,5 @@ using System.Drawing; using System.IO; -using System.Linq; -using System.IO; namespace AltNetHispano.Agendas.Domain { diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Domain/Persona.cs --- a/Agendas/trunk/src/Agendas.Domain/Persona.cs Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Domain/Persona.cs Mon Aug 01 00:28:04 2011 -0300 @@ -55,7 +55,7 @@ public enum IdentityProviderEnum { - BuiltIn = 1, + Google = 1, Twitter = 2 } } \ No newline at end of file diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs --- a/Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Tests/PersonaServiceTests.cs Mon Aug 01 00:28:04 2011 -0300 @@ -37,10 +37,10 @@ } [Test] - public void IdentificacionBuiltIn() + public void IdentificacionGoogle() { - var builtIn = new Identification(Identification.Map[(int) IdentityProviderEnum.BuiltIn] + "nelo"); - Assert.AreEqual(IdentityProviderEnum.BuiltIn, builtIn.IdentityProvider); + var builtIn = new Identification(Identification.Map[(int)IdentityProviderEnum.Google] + "nelo"); + Assert.AreEqual(IdentityProviderEnum.Google, builtIn.IdentityProvider); Assert.AreEqual("nelo", builtIn.LogonName); } diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj --- a/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Agendas.Web.csproj Mon Aug 01 00:28:04 2011 -0300 @@ -76,17 +76,14 @@ - - - @@ -143,10 +140,7 @@ - - - @@ -199,9 +193,6 @@ - - - diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs --- a/Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Controllers/AccountController.cs Mon Aug 01 00:28:04 2011 -0300 @@ -13,48 +13,19 @@ { 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); } - // ************************************** - // URL: /Account/LogOn - // ************************************** - public ActionResult LogOn() { return View(); } - [HttpPost] - public ActionResult LogOn(LogOnModel model, string returnUrl) - { - if (ModelState.IsValid) - { - if (MembershipService.ValidateUser(model.UserName, model.Password)) - { - var personaService = AgendaFactory.GetPersonaService(); - if (personaService.Validate(IdentityProviderEnum.BuiltIn, model.UserName)) - { - FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.BuiltIn] + model.UserName, model.RememberMe); - if (Url.IsLocalUrl(returnUrl)) - return Redirect(returnUrl); - return RedirectToAction("Index", "Home"); - } - } - ModelState.AddModelError("", "The user name or password provided is incorrect."); - } - - // If we got this far, something failed, redisplay form - return View(model); - } - public ActionResult TwitterLogOn() { var oAuth = new OAuthTwitter(); @@ -86,94 +57,10 @@ return RedirectToAction("LogOn"); } - // ************************************** - // URL: /Account/LogOff - // ************************************** - public ActionResult LogOff() { FormsService.SignOut(); - return RedirectToAction("Index", "Home"); } - - // ************************************** - // URL: /Account/Register - // ************************************** - - public ActionResult Register() - { - ViewBag.PasswordLength = MembershipService.MinPasswordLength; - return View(); - } - - [HttpPost] - public ActionResult Register(RegisterModel model, string returnUrl) - { - if (ModelState.IsValid) - { - // Attempt to register the user - MembershipCreateStatus createStatus = MembershipService.CreateUser(model.UserName, model.Password, model.Email); - - if (createStatus == MembershipCreateStatus.Success) - { - var personaService = AgendaFactory.GetPersonaService(); - if (personaService.CreateIfNotExist(IdentityProviderEnum.BuiltIn, model.UserName, model.Nombre)) - { - FormsService.SignIn(Identification.Map[(int)IdentityProviderEnum.BuiltIn] + model.UserName, false); - if (Url.IsLocalUrl(returnUrl)) - return Redirect(returnUrl); - return RedirectToAction("Index", "Home"); - } - } - ModelState.AddModelError("", AccountValidation.ErrorCodeToString(createStatus)); - } - - // If we got this far, something failed, redisplay form - ViewBag.PasswordLength = MembershipService.MinPasswordLength; - return View(model); - } - - // ************************************** - // URL: /Account/ChangePassword - // ************************************** - - [Authorize] - public ActionResult ChangePassword() - { - ViewBag.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 - ViewBag.PasswordLength = MembershipService.MinPasswordLength; - return View(model); - } - - // ************************************** - // URL: /Account/ChangePasswordSuccess - // ************************************** - - public ActionResult ChangePasswordSuccess() - { - return View(); - } - } } diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Controllers/PerfilController.cs --- a/Agendas/trunk/src/Agendas.Web/Controllers/PerfilController.cs Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Controllers/PerfilController.cs Mon Aug 01 00:28:04 2011 -0300 @@ -1,31 +1,15 @@ using System; using System.Linq; using System.Web.Mvc; -using System.Web.Routing; using AltNetHispano.Agendas.Domain; using AltNetHispano.Agendas.Factories; using AltNetHispano.Agendas.Twitter; using AltNetHispano.Agendas.Web.Models; -using AltNetHispano.Agendas.Web.Services; namespace AltNetHispano.Agendas.Web.Controllers { public class PerfilController : Controller { - 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); - } - - // - // GET: /Perfil/ - public ActionResult Index() { var persona = IdentityContext.GetUsuario(); @@ -48,7 +32,12 @@ return View(model); } - public ActionResult AddTwitterAccount() + public ActionResult AddGoogleAccount() + { + throw new NotImplementedException(); + } + + public ActionResult AddTwitterAccount() { var oAuth = new OAuthTwitter(); @@ -74,29 +63,6 @@ return RedirectToAction("Index"); } - public ActionResult AddBuiltInAccount() - { - return View(); - } - - [HttpPost] - public ActionResult AddBuiltInAccount(LogOnModel model) - { - if (ModelState.IsValid) - { - if (MembershipService.ValidateUser(model.UserName, model.Password)) - { - var personaService = AgendaFactory.GetPersonaService(); - personaService.AddCuenta(IdentityProviderEnum.BuiltIn, model.UserName); - return RedirectToAction("Index"); - } - ModelState.AddModelError("", "The user name or password provided is incorrect."); - } - - // If we got this far, something failed, redisplay form - return View(model); - } - public ActionResult Remove(string identityProvider, string username) { var personaService = AgendaFactory.GetPersonaService(); diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Models/AccountModels.cs --- a/Agendas/trunk/src/Agendas.Web/Models/AccountModels.cs Mon Aug 01 00:10:20 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Globalization; -using System.Web.Mvc; -using System.Web.Security; - -namespace AltNetHispano.Agendas.Web.Models -{ - - #region Models - - public class ChangePasswordModel - { - [Required] - [DataType(DataType.Password)] - [Display(Name = "Current password")] - public string OldPassword { get; set; } - - [Required] - [ValidatePasswordLength] - [DataType(DataType.Password)] - [Display(Name = "New password")] - public string NewPassword { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm new password")] - [Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } - - public class LogOnModel - { - [Required] - [Display(Name = "User name")] - public string UserName { get; set; } - - [Required] - [DataType(DataType.Password)] - [Display(Name = "Password")] - public string Password { get; set; } - - [Display(Name = "Remember me?")] - public bool RememberMe { get; set; } - } - - - public class RegisterModel - { - [Required] - public string Nombre { get; set; } - - [Required] - [Display(Name = "User name")] - public string UserName { get; set; } - - [Required] - [DataType(DataType.EmailAddress)] - [Display(Name = "Email address")] - public string Email { get; set; } - - [Required] - [ValidatePasswordLength] - [DataType(DataType.Password)] - [Display(Name = "Password")] - public string Password { get; set; } - - [DataType(DataType.Password)] - [Display(Name = "Confirm password")] - [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] - public string ConfirmPassword { get; set; } - } - #endregion - - #region Validation - public static class AccountValidation - { - public static string ErrorCodeToString(MembershipCreateStatus createStatus) - { - // See http://go.microsoft.com/fwlink/?LinkID=177550 for - // a full list of status codes. - switch (createStatus) - { - case MembershipCreateStatus.DuplicateUserName: - return "Username already exists. Please enter a different user name."; - - case MembershipCreateStatus.DuplicateEmail: - return "A username for that e-mail address already exists. Please enter a different e-mail address."; - - case MembershipCreateStatus.InvalidPassword: - return "The password provided is invalid. Please enter a valid password value."; - - case MembershipCreateStatus.InvalidEmail: - return "The e-mail address provided is invalid. Please check the value and try again."; - - case MembershipCreateStatus.InvalidAnswer: - return "The password retrieval answer provided is invalid. Please check the value and try again."; - - case MembershipCreateStatus.InvalidQuestion: - return "The password retrieval question provided is invalid. Please check the value and try again."; - - case MembershipCreateStatus.InvalidUserName: - return "The user name provided is invalid. Please check the value and try again."; - - case MembershipCreateStatus.ProviderError: - return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator."; - - case MembershipCreateStatus.UserRejected: - return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator."; - - default: - return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."; - } - } - } - - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] - public sealed class ValidatePasswordLengthAttribute : ValidationAttribute, IClientValidatable - { - private const string _defaultErrorMessage = "'{0}' must be at least {1} characters long."; - private readonly int _minCharacters = Membership.Provider.MinRequiredPasswordLength; - - public ValidatePasswordLengthAttribute() - : base(_defaultErrorMessage) - { - } - - public override string FormatErrorMessage(string name) - { - return String.Format(CultureInfo.CurrentCulture, ErrorMessageString, - name, _minCharacters); - } - - public override bool IsValid(object value) - { - string valueAsString = value as string; - return (valueAsString != null && valueAsString.Length >= _minCharacters); - } - - public IEnumerable GetClientValidationRules(ModelMetadata metadata, ControllerContext context) - { - return new[]{ - new ModelClientValidationStringLengthRule(FormatErrorMessage(metadata.GetDisplayName()), _minCharacters, int.MaxValue) - }; - } - } - #endregion -} diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Services/AccountMembershipService.cs --- a/Agendas/trunk/src/Agendas.Web/Services/AccountMembershipService.cs Mon Aug 01 00:10:20 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -using System; -using System.Web.Security; - -namespace AltNetHispano.Agendas.Web.Services -{ - public class AccountMembershipService : IMembershipService - { - private readonly MembershipProvider _provider; - - public AccountMembershipService() - : this(null) - { - } - - public AccountMembershipService(MembershipProvider provider) - { - _provider = provider ?? Membership.Provider; - } - - public int MinPasswordLength - { - get - { - return _provider.MinRequiredPasswordLength; - } - } - - public bool ValidateUser(string userName, string password) - { - if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); - if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password"); - - return _provider.ValidateUser(userName, password); - } - - public MembershipCreateStatus CreateUser(string userName, string password, string email) - { - if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); - if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password"); - if (String.IsNullOrEmpty(email)) throw new ArgumentException("Value cannot be null or empty.", "email"); - - MembershipCreateStatus status; - _provider.CreateUser(userName, password, email, null, null, true, null, out status); - return status; - } - - public bool ChangePassword(string userName, string oldPassword, string newPassword) - { - if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); - if (String.IsNullOrEmpty(oldPassword)) throw new ArgumentException("Value cannot be null or empty.", "oldPassword"); - if (String.IsNullOrEmpty(newPassword)) throw new ArgumentException("Value cannot be null or empty.", "newPassword"); - - // The underlying ChangePassword() will throw an exception rather - // than return false in certain failure scenarios. - try - { - MembershipUser currentUser = _provider.GetUser(userName, true /* userIsOnline */); - return currentUser.ChangePassword(oldPassword, newPassword); - } - catch (ArgumentException) - { - return false; - } - catch (MembershipPasswordException) - { - return false; - } - } - } -} \ No newline at end of file diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Services/IMembershipService.cs --- a/Agendas/trunk/src/Agendas.Web/Services/IMembershipService.cs Mon Aug 01 00:10:20 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -using System.Web.Security; - -namespace AltNetHispano.Agendas.Web.Services -{ - public interface IMembershipService - { - int MinPasswordLength { get; } - - bool ValidateUser(string userName, string password); - MembershipCreateStatus CreateUser(string userName, string password, string email); - bool ChangePassword(string userName, string oldPassword, string newPassword); - } -} \ No newline at end of file diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Views/Account/ChangePassword.cshtml --- a/Agendas/trunk/src/Agendas.Web/Views/Account/ChangePassword.cshtml Mon Aug 01 00:10:20 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -@model AltNetHispano.Agendas.Web.Models.ChangePasswordModel -

Change Password

-

- Use the form below to change your password. -

-

- New passwords are required to be a minimum of @ViewBag.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 -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Views/Account/ChangePasswordSuccess.cshtml --- a/Agendas/trunk/src/Agendas.Web/Views/Account/ChangePasswordSuccess.cshtml Mon Aug 01 00:10:20 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -

Change Password

-

- Your password has been changed successfully. -

diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Views/Account/LogOn.cshtml --- a/Agendas/trunk/src/Agendas.Web/Views/Account/LogOn.cshtml Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Views/Account/LogOn.cshtml Mon Aug 01 00:28:04 2011 -0300 @@ -1,44 +1,20 @@ -@model AltNetHispano.Agendas.Web.Models.LogOnModel -

Log On

+

Log On

- Please enter your username and password. @Html.ActionLink("Register", "Register") if you don't have an account. + Seleccione el proveedor con que quiere demostrar su identidad

-@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.") - -@using (Html.BeginForm()) { -
-
- Account Information - -
- @Html.LabelFor(m => m.UserName) -
-
- @Html.TextBoxFor(m => m.UserName) - @Html.ValidationMessageFor(m => m.UserName) -
- -
- @Html.LabelFor(m => m.Password) -
-
- @Html.PasswordFor(m => m.Password) - @Html.ValidationMessageFor(m => m.Password) -
- -
- @Html.CheckBoxFor(m => m.RememberMe) - @Html.LabelFor(m => m.RememberMe) -
- -

- -

-
-
-} -Sign in with twitter +
+
+ Proveedores de identidad habilitados +
+ + + + + +
Sign in with twitterIdentifíquese utilizando su cuenta de twitter
+
+
\ No newline at end of file diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Views/Account/Register.cshtml --- a/Agendas/trunk/src/Agendas.Web/Views/Account/Register.cshtml Mon Aug 01 00:10:20 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -@model AltNetHispano.Agendas.Web.Models.RegisterModel -

Create a New Account

-

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

-

- Passwords are required to be a minimum of @ViewBag.PasswordLength characters in length. -

- - - - -@using (Html.BeginForm()) { - @Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") - @Html.EditorForModel() -

- -

-} diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Views/Perfil/AddBuiltInAccount.cshtml --- a/Agendas/trunk/src/Agendas.Web/Views/Perfil/AddBuiltInAccount.cshtml Mon Aug 01 00:10:20 2011 -0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -@model AltNetHispano.Agendas.Web.Models.LogOnModel -

Perfil

-

- Hola estas son tus cuentas registradas -

-@Html.ValidationSummary(true, "La validación no fue exitosa, por favor intente de nuevo") - -@using (Html.BeginForm()) { -
-
- Información de la cuenta interna - -
- @Html.LabelFor(m => m.UserName) -
-
- @Html.TextBoxFor(m => m.UserName) - @Html.ValidationMessageFor(m => m.UserName) -
- -
- @Html.LabelFor(m => m.Password) -
-
- @Html.PasswordFor(m => m.Password) - @Html.ValidationMessageFor(m => m.Password) -
- -

- -

-
-
-} - -

-@Html.ActionLink("Volver", "Index") -

diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Views/Perfil/Index.cshtml --- a/Agendas/trunk/src/Agendas.Web/Views/Perfil/Index.cshtml Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Views/Perfil/Index.cshtml Mon Aug 01 00:28:04 2011 -0300 @@ -27,8 +27,8 @@

@Html.ActionLink("Asociar cuenta de Twitter", "AddTwitterAccount") -
-@Html.ActionLink("Asociar cuenta de interna", "AddBuiltInAccount") + +
diff -r a5ff4de4a1d3 -r 62dc9fb3a03e Agendas/trunk/src/Agendas.Web/Web.config --- a/Agendas/trunk/src/Agendas.Web/Web.config Mon Aug 01 00:10:20 2011 -0300 +++ b/Agendas/trunk/src/Agendas.Web/Web.config Mon Aug 01 00:28:04 2011 -0300 @@ -6,7 +6,6 @@ -