2009-11-10 Marek Habersack <mhabersack@novell.com>
authorMarek Habersack <grendel@twistedcode.net>
Tue, 10 Nov 2009 10:41:41 +0000 (10:41 -0000)
committerMarek Habersack <grendel@twistedcode.net>
Tue, 10 Nov 2009 10:41:41 +0000 (10:41 -0000)
* PasswordRecovery.cs:
{Question,Success,UserName}TemplateContainer must all be populated
the first time the property is accessed, so that calling
FindControl on the container returns valid and expected
results. If the associated template is not defined, though,
populating is postponed till CreateChildControls is called -
that's where default, empty, template will be created. This is
required to fix YetAnotherForum's password recovery control.
Mail template used in SendPasswordByMail must match the one used
in .NET (it has to end with a newline) as YAF parses the message
to retrieve user name and password and breaks if the last line
doesn't end with a newline character.

svn path=/trunk/mcs/; revision=145824

mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog
mcs/class/System.Web/System.Web.UI.WebControls/PasswordRecovery.cs

index 9d6ef99ccb434ce3b05fdb51b55b4c4831e018ef..1d29a2723602c012577ce665c6c3b23f810bd566 100644 (file)
@@ -1,3 +1,18 @@
+2009-11-10  Marek Habersack  <mhabersack@novell.com>
+
+       * PasswordRecovery.cs:
+       {Question,Success,UserName}TemplateContainer must all be populated
+       the first time the property is accessed, so that calling
+       FindControl on the container returns valid and expected
+       results. If the associated template is not defined, though,
+       populating is postponed till CreateChildControls is called -
+       that's where default, empty, template will be created. This is
+       required to fix YetAnotherForum's password recovery control.
+       Mail template used in SendPasswordByMail must match the one used
+       in .NET (it has to end with a newline) as YAF parses the message
+       to retrieve user name and password and breaks if the last line
+       doesn't end with a newline character.
+
 2009-10-30  Marek Habersack  <mhabersack@novell.com>
 
        * PasswordRecovery.cs: mail message replacements should include <%
index c943a7ce9d9d62a74a1ffd07010678ac64e04800..708030e50f3c6ed25e6a4246c8b033a8c979d2ed 100644 (file)
@@ -337,10 +337,14 @@ namespace System.Web.UI.WebControls
 
                public Control QuestionTemplateContainer
                {
-                       get
-                       {
-                               if (_questionTemplateContainer == null)
+                       get {
+                               if (_questionTemplateContainer == null) {
                                        _questionTemplateContainer = new QuestionContainer (this);
+                                       ITemplate template = QuestionTemplate;
+                                       if (template != null)
+                                               _questionTemplateContainer.InstantiateTemplate (template);
+                               }
+                               
                                return _questionTemplateContainer;
                        }
                }
@@ -354,10 +358,14 @@ namespace System.Web.UI.WebControls
 
                public Control SuccessTemplateContainer
                {
-                       get
-                       {
-                               if (_successTemplateContainer == null)
+                       get {
+                               if (_successTemplateContainer == null) {
                                        _successTemplateContainer = new SuccessContainer (this);
+                                       ITemplate template = SuccessTemplate;
+                                       if (template != null)
+                                               _successTemplateContainer.InstantiateTemplate (template);
+                               }
+                               
                                return _successTemplateContainer;
                        }
                }
@@ -373,8 +381,13 @@ namespace System.Web.UI.WebControls
                {
                        get
                        {
-                               if (_userNameTemplateContainer == null)
+                               if (_userNameTemplateContainer == null) {
                                        _userNameTemplateContainer = new UserNameContainer (this);
+                                       ITemplate template = UserNameTemplate;
+                                       if (template != null)
+                                               _userNameTemplateContainer.InstantiateTemplate (template);
+                               }
+                               
                                return _userNameTemplateContainer;
                        }
                }
@@ -519,19 +532,22 @@ namespace System.Web.UI.WebControls
                protected internal override void CreateChildControls ()
                {
                        ITemplate userNameTemplate = UserNameTemplate;
-                       if (userNameTemplate == null)
+                       if (userNameTemplate == null) {
                                userNameTemplate = new UserNameDefaultTemplate (this);
-                       ((UserNameContainer) UserNameTemplateContainer).InstantiateTemplate (userNameTemplate);
-
+                               ((UserNameContainer) UserNameTemplateContainer).InstantiateTemplate (userNameTemplate);
+                       }
+                       
                        ITemplate questionTemplate = QuestionTemplate;
-                       if (questionTemplate == null)
+                       if (questionTemplate == null) {
                                questionTemplate = new QuestionDefaultTemplate (this);
-                       ((QuestionContainer) QuestionTemplateContainer).InstantiateTemplate (questionTemplate);
+                               ((QuestionContainer) QuestionTemplateContainer).InstantiateTemplate (questionTemplate);
+                       }
 
                        ITemplate successTemplate = SuccessTemplate;
-                       if (successTemplate == null)
+                       if (successTemplate == null) {
                                successTemplate = new SuccessDefaultTemplate (this);
-                       ((SuccessContainer) SuccessTemplateContainer).InstantiateTemplate (successTemplate);
+                               ((SuccessContainer) SuccessTemplateContainer).InstantiateTemplate (successTemplate);
+                       }
 
                        Controls.AddAt (0, UserNameTemplateContainer);
                        Controls.AddAt (1, QuestionTemplateContainer);
@@ -791,8 +807,10 @@ namespace System.Web.UI.WebControls
                        if (user == null)
                                return;
 
+                       // DO NOT change format of the message - it has to be exactly the same as in
+                       // .NET as some software (e.g. YetAnotherForum) depends on it.
                        string messageText = "Please return to the site and log in using the following information.\n" +
-                               "User Name: <%USERNAME%>\nPassword: <%PASSWORD%>";
+                               "User Name: <%USERNAME%>\nPassword: <%PASSWORD%>\n";
 
                        ListDictionary dictionary = new ListDictionary (StringComparer.OrdinalIgnoreCase);
                        dictionary.Add ("<%USERNAME%>", username);