* AccountController.cs: Register and reset passord
from Web API * GCMController.cs: initial creation, will host GCM calls and related procedures. * ResetPassword.aspx: Html view to reset the password * LocalizedText.resx: * LocalizedText.fr.resx: new String form circles * Web.config: * Web.csproj: * YavscModel.csproj: * LocalizedText.Designer.cs: * Profile.cs: * Profile.cs: * LocalizedText.fr.Designer.cs: * LoginModel.cs: * Publishing.cs: * CalendarController.cs: * LoginModel.cs: * GCMRegister.cs: * Publishing.cs: * GCMRegister.cs: * NewRoleModel.cs: * NewRoleModel.cs: * RegisterModel.cs: * NewAdminModel.cs: * RegisterModel.cs: * NewAdminModel.cs: * LostPasswordModel.cs: * RegisterViewModel.cs: * RegisterViewModel.cs: * ProviderPublicInfo.cs: * RegisterClientModel.cs: * ChangePasswordModel.cs: * ProviderPublicInfo.cs: * RegisterClientModel.cs: * ChangePasswordModel.cs: Fixes a typo (in the namespace :-/) * NpgsqlCircleProvider.cs: Fixes the Circle creation * Global.asax.cs: * AdminController.cs: * NpgsqlContentProvider.cs: code formatting * BlogsController.cs: * CircleController.cs: * WorkFlowController.cs: * PaypalApiController.cs: * FrontOfficeController.cs: refactoring * AccountController.cs: Adds the way to reset the password * FrontOfficeController.cs: xml doc * T.cs: Make this class an helper to translation * YavscHelpers.cs: Implements the e-mail sending * style.css: style uniformization * Circles.aspx: Implements the Html interface to Circle creation (modifications and deletions are still to implement) * Register.ascx: Allows the error display in case of lack of power of the user at registering another user. * Estimate.aspx: use the partial view to register from the Account folder. Cleans the useless reference to ~/Theme/dark/style.css, that was for using the "tablesorter.js", no used anymore. * Web.config: Trying to have all the Index pages to work...
This commit is contained in:
@ -15,8 +15,9 @@ namespace Yavsc.Helpers
|
||||
/// <summary>
|
||||
/// T.
|
||||
/// </summary>
|
||||
public class T
|
||||
public static class T
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets the string.
|
||||
/// </summary>
|
||||
@ -27,5 +28,12 @@ namespace Yavsc.Helpers
|
||||
string tr = LocalizedText.ResourceManager.GetString (msg.Replace (" ", "_"));
|
||||
return tr==null?msg:tr;
|
||||
}
|
||||
|
||||
public static string Translate(this HtmlHelper helper, string text)
|
||||
{
|
||||
// Just call the other one, to avoid having two copies (we don't use the HtmlHelper).
|
||||
return GetString(text);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,10 @@ using System.Web.Security;
|
||||
using System.IO;
|
||||
using System.Web.Configuration;
|
||||
using System.Net.Mail;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using Yavsc.Model.RolesAndMembers;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
|
||||
namespace Yavsc.Helpers
|
||||
{
|
||||
@ -13,8 +17,7 @@ namespace Yavsc.Helpers
|
||||
/// </summary>
|
||||
public static class YavscHelpers
|
||||
{
|
||||
private static string registrationMessage =
|
||||
WebConfigurationManager.AppSettings ["RegistrationMessage"];
|
||||
|
||||
|
||||
|
||||
private static string siteName = null;
|
||||
@ -43,10 +46,21 @@ namespace Yavsc.Helpers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the activation email.
|
||||
/// Sends the activation message.
|
||||
/// </summary>
|
||||
/// <param name="user">User.</param>
|
||||
public static void SendActivationEmail(MembershipUser user) {
|
||||
public static void SendActivationMessage(MembershipUser user)
|
||||
{
|
||||
SendEmail (WebConfigurationManager.AppSettings ["RegistrationMessage"],
|
||||
user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the email.
|
||||
/// </summary>
|
||||
/// <param name="registrationMessage">Registration message.</param>
|
||||
/// <param name="user">User.</param>
|
||||
public static void SendEmail(string registrationMessage, MembershipUser user) {
|
||||
FileInfo fi = new FileInfo (
|
||||
HttpContext.Current.Server.MapPath (registrationMessage));
|
||||
if (!fi.Exists) {
|
||||
@ -79,6 +93,48 @@ namespace Yavsc.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the password.
|
||||
/// </summary>
|
||||
/// <param name="modelState">Model state.</param>
|
||||
/// <param name="model">Model.</param>
|
||||
public static void ResetPassword(LostPasswordModel model, out StringDictionary errors)
|
||||
{
|
||||
MembershipUserCollection users = null;
|
||||
errors = new StringDictionary ();
|
||||
|
||||
if (!string.IsNullOrEmpty (model.UserName)) {
|
||||
users =
|
||||
Membership.FindUsersByName (model.UserName);
|
||||
if (users.Count < 1) {
|
||||
errors.Add ("UserName", "User name not found");
|
||||
return ;
|
||||
}
|
||||
if (users.Count != 1) {
|
||||
errors.Add ("UserName", "Found more than one user!(sic)");
|
||||
return ;
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty (model.Email)) {
|
||||
users =
|
||||
Membership.FindUsersByEmail (model.Email);
|
||||
if (users.Count < 1) {
|
||||
errors.Add ( "Email", "Email not found");
|
||||
return ;
|
||||
}
|
||||
if (users.Count != 1) {
|
||||
errors.Add ("Email", "Found more than one user!(sic)");
|
||||
return ;
|
||||
}
|
||||
}
|
||||
if (users==null)
|
||||
return;
|
||||
// Assert users.Count == 1
|
||||
if (users.Count != 1)
|
||||
throw new InvalidProgramException ("Emails and user's names are uniques, and we find more than one result here, aborting.");
|
||||
foreach (MembershipUser u in users)
|
||||
YavscHelpers.SendActivationMessage (u);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user