PasswordRecovery.cs 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351
  1. //
  2. // System.Web.UI.WebControls.PasswordRecovery.cs
  3. //
  4. // Authors:
  5. // Vladimir Krasnov ([email protected])
  6. //
  7. // (C) 2006 Mainsoft, Inc (http://www.mainsoft.com)
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. #if NET_2_0
  29. using System;
  30. using System.Net.Mail;
  31. using System.Collections;
  32. using System.Collections.Specialized;
  33. using System.ComponentModel;
  34. using System.Drawing.Design;
  35. using System.Web;
  36. using System.Web.UI;
  37. using System.Web.Security;
  38. namespace System.Web.UI.WebControls
  39. {
  40. [Bindable (false)]
  41. public class PasswordRecovery : CompositeControl
  42. {
  43. static readonly object answerLookupErrorEvent = new object ();
  44. static readonly object sendingMailEvent = new object ();
  45. static readonly object sendMailErrorEvent = new object ();
  46. static readonly object userLookupErrorEvent = new object ();
  47. static readonly object verifyingAnswerEvent = new object ();
  48. static readonly object verifyingUserEvent = new object ();
  49. public static readonly string SubmitButtonCommandName = "Submit";
  50. TableItemStyle _failureTextStyle;
  51. TableItemStyle _hyperLinkStyle;
  52. TableItemStyle _instructionTextStyle;
  53. TableItemStyle _labelStyle;
  54. Style _submitButtonStyle;
  55. TableItemStyle _successTextStyle;
  56. Style _textBoxStyle;
  57. TableItemStyle _titleTextStyle;
  58. Style _validatorTextStyle;
  59. MailDefinition _mailDefinition;
  60. MembershipProvider _provider = null;
  61. ITemplate _questionTemplate = null;
  62. ITemplate _successTemplate = null;
  63. ITemplate _userNameTemplate = null;
  64. QuestionContainer _questionTemplateContainer = null;
  65. SuccessContainer _successTemplateContainer = null;
  66. UserNameContainer _userNameTemplateContainer = null;
  67. PasswordReciveryStep _currentStep = PasswordReciveryStep.StepUserName;
  68. string _username = null;
  69. string _answer = null;
  70. EventHandlerList events = new EventHandlerList ();
  71. #region Events
  72. public event EventHandler AnswerLookupError {
  73. add { events.AddHandler (answerLookupErrorEvent, value); }
  74. remove { events.RemoveHandler (answerLookupErrorEvent, value); }
  75. }
  76. public event MailMessageEventHandler SendingMail {
  77. add { events.AddHandler (sendingMailEvent, value); }
  78. remove { events.RemoveHandler (sendingMailEvent, value); }
  79. }
  80. public event SendMailErrorEventHandler SendMailError {
  81. add { events.AddHandler (sendMailErrorEvent, value); }
  82. remove { events.RemoveHandler (sendMailErrorEvent, value); }
  83. }
  84. public event EventHandler UserLookupError {
  85. add { events.AddHandler (userLookupErrorEvent, value); }
  86. remove { events.RemoveHandler (userLookupErrorEvent, value); }
  87. }
  88. public event LoginCancelEventHandler VerifyingAnswer {
  89. add { events.AddHandler (verifyingAnswerEvent, value); }
  90. remove { events.RemoveHandler (verifyingAnswerEvent, value); }
  91. }
  92. public event LoginCancelEventHandler VerifyingUser {
  93. add { events.AddHandler (verifyingUserEvent, value); }
  94. remove { events.RemoveHandler (verifyingUserEvent, value); }
  95. }
  96. #endregion
  97. public PasswordRecovery ()
  98. {
  99. }
  100. [Themeable (false)]
  101. public virtual string Answer
  102. {
  103. get { return _answer != null ? _answer : string.Empty; }
  104. }
  105. [Localizable (true)]
  106. public virtual string AnswerLabelText
  107. {
  108. get { return ViewState.GetString ("AnswerLabelText", "Answer:"); }
  109. set { ViewState ["AnswerLabelText"] = value; }
  110. }
  111. [Localizable (true)]
  112. public virtual string AnswerRequiredErrorMessage
  113. {
  114. get { return ViewState.GetString ("AnswerRequiredErrorMessage", "Answer is required."); }
  115. set { ViewState ["AnswerRequiredErrorMessage"] = value; }
  116. }
  117. public virtual int BorderPadding
  118. {
  119. get { return ViewState.GetInt ("BorderPadding", 1); }
  120. set
  121. {
  122. if (value < -1)
  123. throw new ArgumentOutOfRangeException ();
  124. ViewState ["BorderPadding"] = value;
  125. }
  126. }
  127. [Localizable (true)]
  128. public virtual string GeneralFailureText
  129. {
  130. get { return ViewState.GetString ("GeneralFailureText", "Your attempt to retrieve your password was not successful. Please try again."); }
  131. set { ViewState ["GeneralFailureText"] = value; }
  132. }
  133. public virtual string HelpPageIconUrl
  134. {
  135. get { return ViewState.GetString ("HelpPageIconUrl", String.Empty); }
  136. set { ViewState ["HelpPageIconUrl"] = value; }
  137. }
  138. [Localizable (true)]
  139. public virtual string HelpPageText
  140. {
  141. get { return ViewState.GetString ("HelpPageText", String.Empty); }
  142. set { ViewState ["HelpPageText"] = value; }
  143. }
  144. public virtual string HelpPageUrl
  145. {
  146. get { return ViewState.GetString ("HelpPageUrl", String.Empty); }
  147. set { ViewState ["HelpPageUrl"] = value; }
  148. }
  149. [Themeable (false)]
  150. public MailDefinition MailDefinition
  151. {
  152. get
  153. {
  154. if (_mailDefinition == null) {
  155. _mailDefinition = new MailDefinition ();
  156. if (IsTrackingViewState)
  157. ((IStateManager) _mailDefinition).TrackViewState ();
  158. }
  159. return _mailDefinition;
  160. }
  161. }
  162. [Themeable (false)]
  163. public virtual string MembershipProvider
  164. {
  165. get { return ViewState.GetString ("MembershipProvider", String.Empty); }
  166. set { ViewState ["MembershipProvider"] = value; }
  167. }
  168. [Themeable (false)]
  169. public virtual string Question
  170. {
  171. get { return ViewState.GetString ("Question", ""); }
  172. private set { ViewState ["Question"] = value; }
  173. }
  174. [Localizable (true)]
  175. public virtual string QuestionFailureText
  176. {
  177. get { return ViewState.GetString ("QuestionFailureText", "Your answer could not be verified. Please try again."); }
  178. set { ViewState ["QuestionFailureText"] = value; }
  179. }
  180. [Localizable (true)]
  181. public virtual string QuestionInstructionText
  182. {
  183. get { return ViewState.GetString ("QuestionInstructionText", "Answer the following question to receive your password."); }
  184. set { ViewState ["QuestionInstructionText"] = value; }
  185. }
  186. [Localizable (true)]
  187. public virtual string QuestionLabelText
  188. {
  189. get { return ViewState.GetString ("QuestionLabelText", "Question:"); }
  190. set { ViewState ["QuestionLabelText"] = value; }
  191. }
  192. [Localizable (true)]
  193. public virtual string QuestionTitleText
  194. {
  195. get { return ViewState.GetString ("QuestionTitleText", "Identity Confirmation"); }
  196. set { ViewState ["QuestionTitleText"] = value; }
  197. }
  198. public virtual string SubmitButtonImageUrl
  199. {
  200. get { return ViewState.GetString ("SubmitButtonImageUrl", String.Empty); }
  201. set { ViewState ["SubmitButtonImageUrl"] = value; }
  202. }
  203. [Localizable (true)]
  204. public virtual string SubmitButtonText
  205. {
  206. get { return ViewState.GetString ("SubmitButtonText", "Submit"); }
  207. set { ViewState ["SubmitButtonText"] = value; }
  208. }
  209. public virtual ButtonType SubmitButtonType
  210. {
  211. get
  212. {
  213. object o = ViewState ["SubmitButtonType"];
  214. return (o == null) ? ButtonType.Button : (ButtonType) o;
  215. }
  216. set
  217. {
  218. if ((value < ButtonType.Button) || (value > ButtonType.Link))
  219. throw new ArgumentOutOfRangeException ("SubmitButtonType");
  220. ViewState ["SubmitButtonType"] = (int) value;
  221. }
  222. }
  223. [Themeable (false)]
  224. public virtual string SuccessPageUrl
  225. {
  226. get { return ViewState.GetString ("SuccessPageUrl", String.Empty); }
  227. set { ViewState ["SuccessPageUrl"] = value; }
  228. }
  229. [Localizable (true)]
  230. public virtual string SuccessText
  231. {
  232. get { return ViewState.GetString ("SuccessText", "Your password has been sent to you."); }
  233. set { ViewState ["SuccessText"] = value; }
  234. }
  235. public virtual LoginTextLayout TextLayout
  236. {
  237. get
  238. {
  239. object o = ViewState ["TextLayout"];
  240. return (o == null) ? LoginTextLayout.TextOnLeft : (LoginTextLayout) o;
  241. }
  242. set
  243. {
  244. if ((value < LoginTextLayout.TextOnLeft) || (value > LoginTextLayout.TextOnTop))
  245. throw new ArgumentOutOfRangeException ("TextLayout");
  246. ViewState ["TextLayout"] = (int) value;
  247. }
  248. }
  249. [Localizable (true)]
  250. public virtual string UserName
  251. {
  252. get { return _username != null ? _username : ""; }
  253. set { _username = value; }
  254. }
  255. [Localizable (true)]
  256. public virtual string UserNameFailureText
  257. {
  258. get { return ViewState.GetString ("UserNameFailureText", "We were unable to access your information. Please try again."); }
  259. set { ViewState ["UserNameFailureText"] = value; }
  260. }
  261. [Localizable (true)]
  262. public virtual string UserNameInstructionText
  263. {
  264. get { return ViewState.GetString ("UserNameInstructionText", "Enter your User Name to receive your password."); }
  265. set { ViewState ["UserNameInstructionText"] = value; }
  266. }
  267. [Localizable (true)]
  268. public virtual string UserNameLabelText
  269. {
  270. get { return ViewState.GetString ("UserNameLabelText", "User Name:"); }
  271. set { ViewState ["UserNameLabelText"] = value; }
  272. }
  273. [Localizable (true)]
  274. public virtual string UserNameRequiredErrorMessage
  275. {
  276. get { return ViewState.GetString ("UserNameRequiredErrorMessage", "User Name is required."); }
  277. set { ViewState ["UserNameRequiredErrorMessage"] = value; }
  278. }
  279. [Localizable (true)]
  280. public virtual string UserNameTitleText
  281. {
  282. get { return ViewState.GetString ("UserNameTitleText", "Forgot Your Password?"); }
  283. set { ViewState ["UserNameTitleText"] = value; }
  284. }
  285. [TemplateContainer (typeof (PasswordRecovery))]
  286. public virtual ITemplate QuestionTemplate
  287. {
  288. get { return _questionTemplate; }
  289. set { _questionTemplate = value; }
  290. }
  291. public Control QuestionTemplateContainer
  292. {
  293. get
  294. {
  295. if (_questionTemplateContainer == null)
  296. _questionTemplateContainer = new QuestionContainer (this);
  297. return _questionTemplateContainer;
  298. }
  299. }
  300. [TemplateContainer (typeof (PasswordRecovery))]
  301. public virtual ITemplate SuccessTemplate
  302. {
  303. get { return _successTemplate; }
  304. set { _successTemplate = value; }
  305. }
  306. public Control SuccessTemplateContainer
  307. {
  308. get
  309. {
  310. if (_successTemplateContainer == null)
  311. _successTemplateContainer = new SuccessContainer (this);
  312. return _successTemplateContainer;
  313. }
  314. }
  315. [TemplateContainer (typeof (PasswordRecovery))]
  316. public virtual ITemplate UserNameTemplate
  317. {
  318. get { return _userNameTemplate; }
  319. set { _userNameTemplate = value; }
  320. }
  321. public Control UserNameTemplateContainer
  322. {
  323. get
  324. {
  325. if (_userNameTemplateContainer == null)
  326. _userNameTemplateContainer = new UserNameContainer (this);
  327. return _userNameTemplateContainer;
  328. }
  329. }
  330. public TableItemStyle FailureTextStyle
  331. {
  332. get
  333. {
  334. if (_failureTextStyle == null) {
  335. _failureTextStyle = new TableItemStyle ();
  336. if (IsTrackingViewState)
  337. _failureTextStyle.TrackViewState ();
  338. }
  339. return _failureTextStyle;
  340. }
  341. }
  342. public TableItemStyle HyperLinkStyle
  343. {
  344. get
  345. {
  346. if (_hyperLinkStyle == null) {
  347. _hyperLinkStyle = new TableItemStyle ();
  348. if (IsTrackingViewState)
  349. _hyperLinkStyle.TrackViewState ();
  350. }
  351. return _hyperLinkStyle;
  352. }
  353. }
  354. public TableItemStyle InstructionTextStyle
  355. {
  356. get
  357. {
  358. if (_instructionTextStyle == null) {
  359. _instructionTextStyle = new TableItemStyle ();
  360. if (IsTrackingViewState)
  361. _instructionTextStyle.TrackViewState ();
  362. }
  363. return _instructionTextStyle;
  364. }
  365. }
  366. public TableItemStyle LabelStyle
  367. {
  368. get
  369. {
  370. if (_labelStyle == null) {
  371. _labelStyle = new TableItemStyle ();
  372. if (IsTrackingViewState)
  373. _labelStyle.TrackViewState ();
  374. }
  375. return _labelStyle;
  376. }
  377. }
  378. public Style SubmitButtonStyle
  379. {
  380. get
  381. {
  382. if (_submitButtonStyle == null) {
  383. _submitButtonStyle = new TableItemStyle ();
  384. if (IsTrackingViewState)
  385. _submitButtonStyle.TrackViewState ();
  386. }
  387. return _submitButtonStyle;
  388. }
  389. }
  390. public TableItemStyle SuccessTextStyle
  391. {
  392. get
  393. {
  394. if (_successTextStyle == null) {
  395. _successTextStyle = new TableItemStyle ();
  396. if (IsTrackingViewState)
  397. _successTextStyle.TrackViewState ();
  398. }
  399. return _successTextStyle;
  400. }
  401. }
  402. public Style TextBoxStyle
  403. {
  404. get
  405. {
  406. if (_textBoxStyle == null) {
  407. _textBoxStyle = new TableItemStyle ();
  408. if (IsTrackingViewState)
  409. _textBoxStyle.TrackViewState ();
  410. }
  411. return _textBoxStyle;
  412. }
  413. }
  414. public TableItemStyle TitleTextStyle
  415. {
  416. get
  417. {
  418. if (_titleTextStyle == null) {
  419. _titleTextStyle = new TableItemStyle ();
  420. if (IsTrackingViewState)
  421. _titleTextStyle.TrackViewState ();
  422. }
  423. return _titleTextStyle;
  424. }
  425. }
  426. public Style ValidatorTextStyle
  427. {
  428. get
  429. {
  430. if (_validatorTextStyle == null) {
  431. _validatorTextStyle = new TableItemStyle ();
  432. if (IsTrackingViewState)
  433. _validatorTextStyle.TrackViewState ();
  434. }
  435. return _validatorTextStyle;
  436. }
  437. }
  438. #region Protected Properties
  439. protected override HtmlTextWriterTag TagKey
  440. {
  441. get { return HtmlTextWriterTag.Table; }
  442. }
  443. internal virtual MembershipProvider MembershipProviderInternal
  444. {
  445. get
  446. {
  447. if (_provider == null)
  448. InitMemberShipProvider ();
  449. return _provider;
  450. }
  451. }
  452. #endregion
  453. protected internal override void CreateChildControls ()
  454. {
  455. ITemplate userNameTemplate = UserNameTemplate;
  456. if (userNameTemplate == null)
  457. userNameTemplate = new UserNameDefaultTemplate (this);
  458. ((UserNameContainer) UserNameTemplateContainer).InstantiateTemplate (userNameTemplate);
  459. ITemplate questionTemplate = QuestionTemplate;
  460. if (questionTemplate == null)
  461. questionTemplate = new QuestionDefaultTemplate (this);
  462. ((QuestionContainer) QuestionTemplateContainer).InstantiateTemplate (questionTemplate);
  463. ITemplate successTemplate = SuccessTemplate;
  464. if (successTemplate == null)
  465. successTemplate = new SuccessDefaultTemplate (this);
  466. ((SuccessContainer) SuccessTemplateContainer).InstantiateTemplate (successTemplate);
  467. Controls.AddAt (0, UserNameTemplateContainer);
  468. Controls.AddAt (1, QuestionTemplateContainer);
  469. Controls.AddAt (2, SuccessTemplateContainer);
  470. IEditableTextControl editable;
  471. editable = ((UserNameContainer) UserNameTemplateContainer).UserNameTextBox;
  472. if (editable != null)
  473. editable.TextChanged += new EventHandler (UserName_TextChanged);
  474. editable = ((QuestionContainer) QuestionTemplateContainer).AnswerTextBox;
  475. if (editable != null)
  476. editable.TextChanged += new EventHandler (Answer_TextChanged);
  477. }
  478. #region Protected methods
  479. protected internal override void Render (HtmlTextWriter writer)
  480. {
  481. ((QuestionContainer) QuestionTemplateContainer).UpdateChildControls ();
  482. for (int i = 0; i < Controls.Count; i++)
  483. if (Controls [i].Visible)
  484. Controls [i].Render (writer);
  485. }
  486. protected internal override void LoadControlState (object savedState)
  487. {
  488. if (savedState == null) return;
  489. object [] state = (object []) savedState;
  490. base.LoadControlState (state [0]);
  491. _currentStep = (PasswordReciveryStep) state [1];
  492. _username = (string) state [2];
  493. }
  494. protected internal override object SaveControlState ()
  495. {
  496. object state = base.SaveControlState ();
  497. return new object [] { state, _currentStep, _username };
  498. }
  499. protected override void TrackViewState ()
  500. {
  501. base.TrackViewState ();
  502. if (_failureTextStyle != null)
  503. _failureTextStyle.TrackViewState ();
  504. if (_hyperLinkStyle != null)
  505. _hyperLinkStyle.TrackViewState ();
  506. if (_instructionTextStyle != null)
  507. _instructionTextStyle.TrackViewState ();
  508. if (_labelStyle != null)
  509. _labelStyle.TrackViewState ();
  510. if (_submitButtonStyle != null)
  511. _submitButtonStyle.TrackViewState ();
  512. if (_successTextStyle != null)
  513. _successTextStyle.TrackViewState ();
  514. if (_textBoxStyle != null)
  515. _textBoxStyle.TrackViewState ();
  516. if (_titleTextStyle != null)
  517. _titleTextStyle.TrackViewState ();
  518. if (_validatorTextStyle != null)
  519. _validatorTextStyle.TrackViewState ();
  520. if (_mailDefinition != null)
  521. ((IStateManager) _mailDefinition).TrackViewState ();
  522. }
  523. protected override void LoadViewState (object savedState)
  524. {
  525. if (savedState == null)
  526. return;
  527. object [] states = (object []) savedState;
  528. base.LoadViewState (states [0]);
  529. if (states [1] != null)
  530. FailureTextStyle.LoadViewState (states [1]);
  531. if (states [2] != null)
  532. HyperLinkStyle.LoadViewState (states [2]);
  533. if (states [3] != null)
  534. InstructionTextStyle.LoadViewState (states [3]);
  535. if (states [4] != null)
  536. LabelStyle.LoadViewState (states [4]);
  537. if (states [5] != null)
  538. SubmitButtonStyle.LoadViewState (states [5]);
  539. if (states [6] != null)
  540. SuccessTextStyle.LoadViewState (states [6]);
  541. if (states [7] != null)
  542. TextBoxStyle.LoadViewState (states [7]);
  543. if (states [8] != null)
  544. TitleTextStyle.LoadViewState (states [8]);
  545. if (states [9] != null)
  546. ValidatorTextStyle.LoadViewState (states [9]);
  547. if (states [10] != null)
  548. ((IStateManager) MailDefinition).LoadViewState (states [10]);
  549. }
  550. protected override object SaveViewState ()
  551. {
  552. object [] states = new object [11];
  553. states [0] = base.SaveViewState ();
  554. if (_failureTextStyle != null)
  555. states [1] = _failureTextStyle.SaveViewState ();
  556. if (_hyperLinkStyle != null)
  557. states [2] = _hyperLinkStyle.SaveViewState ();
  558. if (_instructionTextStyle != null)
  559. states [3] = _instructionTextStyle.SaveViewState ();
  560. if (_labelStyle != null)
  561. states [4] = _labelStyle.SaveViewState ();
  562. if (_submitButtonStyle != null)
  563. states [5] = _submitButtonStyle.SaveViewState ();
  564. if (_successTextStyle != null)
  565. states [6] = _successTextStyle.SaveViewState ();
  566. if (_textBoxStyle != null)
  567. states [7] = _textBoxStyle.SaveViewState ();
  568. if (_titleTextStyle != null)
  569. states [8] = _titleTextStyle.SaveViewState ();
  570. if (_validatorTextStyle != null)
  571. states [9] = _validatorTextStyle.SaveViewState ();
  572. if (_mailDefinition != null)
  573. states [10] = ((IStateManager) _mailDefinition).SaveViewState ();
  574. for (int i = 0; i < states.Length; i++) {
  575. if (states [i] != null)
  576. return states;
  577. }
  578. return null;
  579. }
  580. #endregion
  581. void ProcessCommand (CommandEventArgs args)
  582. {
  583. if (!Page.IsValid)
  584. return;
  585. switch (_currentStep) {
  586. case PasswordReciveryStep.StepUserName:
  587. ProcessUserName ();
  588. break;
  589. case PasswordReciveryStep.StepAnswer:
  590. ProcessUserAnswer ();
  591. break;
  592. }
  593. }
  594. void ProcessUserName ()
  595. {
  596. LoginCancelEventArgs args = new LoginCancelEventArgs ();
  597. OnVerifyingUser (args);
  598. if (args.Cancel)
  599. return;
  600. MembershipUser user = MembershipProviderInternal.GetUser (UserName, false);
  601. if (user == null) {
  602. OnUserLookupError (EventArgs.Empty);
  603. ((UserNameContainer) UserNameTemplateContainer).FailureTextLiteral.Text = UserNameFailureText;
  604. return;
  605. }
  606. if (!MembershipProviderInternal.RequiresQuestionAndAnswer) {
  607. GenerateAndSendEmail ();
  608. _currentStep = PasswordReciveryStep.StepSuccess;
  609. return;
  610. }
  611. Question = user.PasswordQuestion;
  612. _currentStep = PasswordReciveryStep.StepAnswer;
  613. return;
  614. }
  615. void ProcessUserAnswer ()
  616. {
  617. LoginCancelEventArgs args = new LoginCancelEventArgs ();
  618. OnVerifyingAnswer (args);
  619. if (args.Cancel)
  620. return;
  621. MembershipUser user = MembershipProviderInternal.GetUser (UserName, false);
  622. if (user == null || string.IsNullOrEmpty (user.Email)) {
  623. ((QuestionContainer) QuestionTemplateContainer).FailureTextLiteral.Text = GeneralFailureText;
  624. return;
  625. }
  626. GenerateAndSendEmail ();
  627. _currentStep = PasswordReciveryStep.StepSuccess;
  628. return;
  629. }
  630. void GenerateAndSendEmail ()
  631. {
  632. string newPassword = "";
  633. try {
  634. if (MembershipProviderInternal.EnablePasswordRetrieval) {
  635. newPassword = MembershipProviderInternal.GetPassword (UserName, Answer);
  636. }
  637. else if (MembershipProviderInternal.EnablePasswordReset) {
  638. newPassword = MembershipProviderInternal.ResetPassword (UserName, Answer);
  639. }
  640. else
  641. throw new HttpException ("Membership provider does not support password retrieval or reset.");
  642. }
  643. catch (MembershipPasswordException) {
  644. OnAnswerLookupError (EventArgs.Empty);
  645. ((QuestionContainer) QuestionTemplateContainer).FailureTextLiteral.Text = QuestionFailureText;
  646. return;
  647. }
  648. SendPasswordByMail (UserName, newPassword);
  649. }
  650. void InitMemberShipProvider ()
  651. {
  652. string mp = MembershipProvider;
  653. _provider = (mp.Length == 0) ? _provider = Membership.Provider : Membership.Providers [mp];
  654. if (_provider == null)
  655. throw new HttpException (Locale.GetText ("No provider named '{0}' could be found.", mp));
  656. }
  657. void SendPasswordByMail (string username, string password)
  658. {
  659. MembershipUser user = MembershipProviderInternal.GetUser (UserName, false);
  660. if (user == null)
  661. return;
  662. string messageText = "Please return to the site and log in using the following information.\n" +
  663. "User Name: <%USERNAME%>\nPassword: <%PASSWORD%>";
  664. ListDictionary dictionary = new ListDictionary (StringComparer.OrdinalIgnoreCase);
  665. dictionary.Add ("<%USERNAME%>", username);
  666. dictionary.Add ("<% UserName %>", username);
  667. dictionary.Add ("<%PASSWORD%>", password);
  668. dictionary.Add ("<% Password %>", password);
  669. MailMessage message = null;
  670. if (MailDefinition.BodyFileName.Length == 0)
  671. message = MailDefinition.CreateMailMessage (user.Email, dictionary, messageText, this);
  672. else
  673. message = MailDefinition.CreateMailMessage (user.Email, dictionary, this);
  674. if (string.IsNullOrEmpty (message.Subject))
  675. message.Subject = "Password";
  676. MailMessageEventArgs args = new MailMessageEventArgs (message);
  677. OnSendingMail (args);
  678. SmtpClient smtpClient = new SmtpClient ();
  679. try {
  680. smtpClient.Send (message);
  681. }
  682. catch (Exception e) {
  683. SendMailErrorEventArgs mailArgs = new SendMailErrorEventArgs (e);
  684. OnSendMailError (mailArgs);
  685. if (!mailArgs.Handled)
  686. throw e;
  687. }
  688. }
  689. #region Event handlers
  690. protected virtual void OnAnswerLookupError (EventArgs e)
  691. {
  692. }
  693. protected override bool OnBubbleEvent (object source, EventArgs e)
  694. {
  695. CommandEventArgs args = e as CommandEventArgs;
  696. if (e != null && args.CommandName == SubmitButtonCommandName) {
  697. ProcessCommand (args);
  698. return true;
  699. }
  700. return base.OnBubbleEvent (source, e);
  701. }
  702. protected internal override void OnInit (EventArgs e)
  703. {
  704. Page.RegisterRequiresControlState (this);
  705. base.OnInit (e);
  706. }
  707. protected internal override void OnPreRender (EventArgs e)
  708. {
  709. UserNameTemplateContainer.Visible = false;
  710. QuestionTemplateContainer.Visible = false;
  711. SuccessTemplateContainer.Visible = false;
  712. switch (_currentStep) {
  713. case PasswordReciveryStep.StepUserName:
  714. UserNameTemplateContainer.Visible = true;
  715. break;
  716. case PasswordReciveryStep.StepAnswer:
  717. QuestionTemplateContainer.Visible = true;
  718. break;
  719. case PasswordReciveryStep.StepSuccess:
  720. SuccessTemplateContainer.Visible = true;
  721. break;
  722. }
  723. base.OnPreRender (e);
  724. }
  725. protected virtual void OnSendingMail (MailMessageEventArgs e)
  726. {
  727. MailMessageEventHandler eh = events [sendingMailEvent] as MailMessageEventHandler;
  728. if (eh != null)
  729. eh (this, e);
  730. }
  731. protected virtual void OnSendMailError (SendMailErrorEventArgs e)
  732. {
  733. SendMailErrorEventHandler eh = events [sendingMailEvent] as SendMailErrorEventHandler;
  734. if (eh != null)
  735. eh (this, e);
  736. }
  737. protected virtual void OnUserLookupError (EventArgs e)
  738. {
  739. EventHandler eh = events [userLookupErrorEvent] as EventHandler;
  740. if (eh != null)
  741. eh (this, e);
  742. }
  743. protected virtual void OnVerifyingAnswer (LoginCancelEventArgs e)
  744. {
  745. LoginCancelEventHandler eh = events [verifyingAnswerEvent] as LoginCancelEventHandler;
  746. if (eh != null)
  747. eh (this, e);
  748. }
  749. protected virtual void OnVerifyingUser (LoginCancelEventArgs e)
  750. {
  751. LoginCancelEventHandler eh = events [verifyingUserEvent] as LoginCancelEventHandler;
  752. if (eh != null)
  753. eh (this, e);
  754. }
  755. #endregion
  756. #region Private Event Handlers
  757. void UserName_TextChanged (object sender, EventArgs e)
  758. {
  759. UserName = ((ITextControl) sender).Text;
  760. }
  761. void Answer_TextChanged (object sender, EventArgs e)
  762. {
  763. _answer = ((ITextControl) sender).Text;
  764. }
  765. #endregion
  766. [MonoTODO ("Not implemented")]
  767. protected override void SetDesignModeState (IDictionary data)
  768. {
  769. throw new NotImplementedException ();
  770. }
  771. abstract class BasePasswordRecoveryContainer : Table, INamingContainer
  772. {
  773. protected readonly PasswordRecovery _owner = null;
  774. TableCell _containerCell = null;
  775. public BasePasswordRecoveryContainer (PasswordRecovery owner)
  776. {
  777. _owner = owner;
  778. InitTable ();
  779. }
  780. public void InstantiateTemplate (ITemplate template)
  781. {
  782. template.InstantiateIn (_containerCell);
  783. }
  784. void InitTable ()
  785. {
  786. Attributes.Add ("ID", _owner.ID);
  787. CellSpacing = 0;
  788. CellPadding = _owner.BorderPadding;
  789. _containerCell = new TableCell ();
  790. TableRow row = new TableRow ();
  791. row.Cells.Add (_containerCell);
  792. Rows.Add (row);
  793. }
  794. protected internal override void OnPreRender (EventArgs e)
  795. {
  796. ApplyStyle (_owner.ControlStyle);
  797. base.OnPreRender (e);
  798. }
  799. public abstract void UpdateChildControls();
  800. }
  801. sealed class QuestionContainer : BasePasswordRecoveryContainer
  802. {
  803. public QuestionContainer (PasswordRecovery owner)
  804. : base (owner)
  805. {
  806. }
  807. // Requried controls
  808. public IEditableTextControl AnswerTextBox
  809. {
  810. get
  811. {
  812. Control c = FindControl ("Answer");
  813. if (c == null)
  814. throw new HttpException ("QuestionTemplate does not contain an IEditableTextControl with ID Answer for the username.");
  815. return c as IEditableTextControl;
  816. }
  817. }
  818. // Optional controls
  819. public Literal UserNameLiteral
  820. {
  821. get { return FindControl ("UserName") as Literal; }
  822. }
  823. public Literal QuestionLiteral
  824. {
  825. get { return FindControl ("Question") as Literal; }
  826. }
  827. public Literal FailureTextLiteral
  828. {
  829. get { return FindControl ("FailureText") as Literal; }
  830. }
  831. public override void UpdateChildControls ()
  832. {
  833. if (UserNameLiteral != null)
  834. UserNameLiteral.Text = _owner.UserName;
  835. if (QuestionLiteral != null)
  836. QuestionLiteral.Text = _owner.Question;
  837. }
  838. }
  839. sealed class SuccessContainer : BasePasswordRecoveryContainer
  840. {
  841. public SuccessContainer (PasswordRecovery owner)
  842. : base (owner)
  843. {
  844. }
  845. public override void UpdateChildControls ()
  846. {
  847. }
  848. }
  849. sealed class UserNameContainer : BasePasswordRecoveryContainer
  850. {
  851. public UserNameContainer (PasswordRecovery owner)
  852. : base (owner)
  853. {
  854. }
  855. // Requried controls
  856. public IEditableTextControl UserNameTextBox
  857. {
  858. get
  859. {
  860. Control c = FindControl ("UserName");
  861. if (c == null)
  862. throw new HttpException ("UserNameTemplate does not contain an IEditableTextControl with ID UserName for the username.");
  863. return c as IEditableTextControl;
  864. }
  865. }
  866. // Optional controls
  867. public ITextControl FailureTextLiteral
  868. {
  869. get { return FindControl ("FailureText") as ITextControl; }
  870. }
  871. public override void UpdateChildControls ()
  872. {
  873. }
  874. }
  875. class TemplateUtils
  876. {
  877. public static TableRow CreateRow(Control c1, Control c2, Style s1, Style s2, bool twoCells)
  878. {
  879. TableRow row = new TableRow ();
  880. TableCell cell1 = new TableCell ();
  881. cell1.Controls.Add (c1);
  882. if (s1 != null)
  883. cell1.ApplyStyle (s1);
  884. row.Cells.Add (cell1);
  885. if (c2 != null) {
  886. TableCell cell2 = new TableCell ();
  887. cell2.Controls.Add (c2);
  888. if (s2 != null)
  889. cell2.ApplyStyle (s2);
  890. row.Cells.Add (cell2);
  891. cell1.HorizontalAlign = HorizontalAlign.Right;
  892. cell2.HorizontalAlign = HorizontalAlign.Left;
  893. }
  894. else {
  895. cell1.HorizontalAlign = HorizontalAlign.Center;
  896. if (twoCells)
  897. cell1.ColumnSpan = 2;
  898. }
  899. return row;
  900. }
  901. public static TableRow CreateHelpRow (string pageUrl, string linkText, string linkIcon, Style linkStyle, bool twoCells)
  902. {
  903. TableRow row = new TableRow ();
  904. TableCell cell1 = new TableCell ();
  905. if (linkIcon.Length > 0) {
  906. Image img = new Image ();
  907. img.ImageUrl = linkIcon;
  908. cell1.Controls.Add (img);
  909. }
  910. if (linkText.Length > 0) {
  911. HyperLink link = new HyperLink ();
  912. link.NavigateUrl = pageUrl;
  913. link.Text = linkText;
  914. link.ControlStyle.CopyTextStylesFrom (linkStyle);
  915. cell1.Controls.Add (link);
  916. }
  917. if (twoCells)
  918. cell1.ColumnSpan = 2;
  919. row.ControlStyle.CopyFrom (linkStyle);
  920. row.Cells.Add (cell1);
  921. return row;
  922. }
  923. }
  924. sealed class UserNameDefaultTemplate : ITemplate
  925. {
  926. readonly PasswordRecovery _owner = null;
  927. public UserNameDefaultTemplate (PasswordRecovery _owner)
  928. {
  929. this._owner = _owner;
  930. }
  931. public void InstantiateIn (Control container)
  932. {
  933. Table table = new Table ();
  934. table.CellPadding = 0;
  935. bool twoCells = _owner.TextLayout == LoginTextLayout.TextOnLeft;
  936. // row 0
  937. table.Rows.Add (
  938. TemplateUtils.CreateRow (new LiteralControl (_owner.UserNameTitleText), null, _owner.TitleTextStyle, null, twoCells));
  939. // row 1
  940. table.Rows.Add (
  941. TemplateUtils.CreateRow (new LiteralControl (_owner.UserNameInstructionText), null, _owner.InstructionTextStyle, null, twoCells));
  942. // row 2
  943. TextBox UserNameTextBox = new TextBox ();
  944. UserNameTextBox.ID = "UserName";
  945. UserNameTextBox.Text = _owner.UserName;
  946. UserNameTextBox.ApplyStyle (_owner.TextBoxStyle);
  947. Label UserNameLabel = new Label ();
  948. UserNameLabel.ID = "UserNameLabel";
  949. UserNameLabel.AssociatedControlID = "UserName";
  950. UserNameLabel.Text = _owner.UserNameLabelText;
  951. UserNameLabel.ApplyStyle (_owner.LabelStyle);
  952. RequiredFieldValidator UserNameRequired = new RequiredFieldValidator ();
  953. UserNameRequired.ID = "UserNameRequired";
  954. UserNameRequired.ControlToValidate = "UserName";
  955. UserNameRequired.ErrorMessage = _owner.UserNameRequiredErrorMessage;
  956. UserNameRequired.ToolTip = _owner.UserNameRequiredErrorMessage;
  957. UserNameRequired.Text = "*";
  958. UserNameRequired.ValidationGroup = _owner.ID;
  959. UserNameRequired.ApplyStyle (_owner.ValidatorTextStyle);
  960. if (twoCells) {
  961. TableRow row = TemplateUtils.CreateRow (UserNameLabel, UserNameTextBox, null, null, twoCells);
  962. row.Cells [1].Controls.Add (UserNameRequired);
  963. table.Rows.Add (row);
  964. }
  965. else {
  966. table.Rows.Add (TemplateUtils.CreateRow (UserNameLabel, null, null, null, twoCells));
  967. TableRow row = TemplateUtils.CreateRow (UserNameTextBox, null, null, null, twoCells);
  968. row.Cells [0].Controls.Add (UserNameRequired);
  969. table.Rows.Add (row);
  970. }
  971. // row 3
  972. Literal FailureText = new Literal ();
  973. FailureText.ID = "FailureText";
  974. if (_owner.FailureTextStyle.ForeColor.IsEmpty)
  975. _owner.FailureTextStyle.ForeColor = System.Drawing.Color.Red;
  976. table.Rows.Add (TemplateUtils.CreateRow (FailureText, null, _owner.FailureTextStyle, null, twoCells));
  977. // row 4
  978. WebControl SubmitButton = null;
  979. switch (_owner.SubmitButtonType) {
  980. case ButtonType.Button:
  981. SubmitButton = new Button ();
  982. break;
  983. case ButtonType.Image:
  984. SubmitButton = new ImageButton ();
  985. break;
  986. case ButtonType.Link:
  987. SubmitButton = new LinkButton ();
  988. break;
  989. }
  990. SubmitButton.ID = "SubmitButton";
  991. SubmitButton.ApplyStyle (_owner.SubmitButtonStyle);
  992. ((IButtonControl) SubmitButton).CommandName = PasswordRecovery.SubmitButtonCommandName;
  993. ((IButtonControl) SubmitButton).Text = _owner.SubmitButtonText;
  994. ((IButtonControl) SubmitButton).ValidationGroup = _owner.ID;
  995. TableRow buttonRow = TemplateUtils.CreateRow (SubmitButton, null, null, null, twoCells);
  996. buttonRow.Cells [0].HorizontalAlign = HorizontalAlign.Right;
  997. table.Rows.Add (buttonRow);
  998. // row 5
  999. table.Rows.Add (
  1000. TemplateUtils.CreateHelpRow (
  1001. _owner.HelpPageUrl, _owner.HelpPageText, _owner.HelpPageIconUrl, _owner.HyperLinkStyle, twoCells));
  1002. container.Controls.Add (table);
  1003. }
  1004. }
  1005. sealed class QuestionDefaultTemplate : ITemplate
  1006. {
  1007. readonly PasswordRecovery _owner = null;
  1008. public QuestionDefaultTemplate (PasswordRecovery _owner)
  1009. {
  1010. this._owner = _owner;
  1011. }
  1012. public void InstantiateIn (Control container)
  1013. {
  1014. Table table = new Table ();
  1015. table.CellPadding = 0;
  1016. bool twoCells = _owner.TextLayout == LoginTextLayout.TextOnLeft;
  1017. // row 0
  1018. table.Rows.Add (
  1019. TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionTitleText), null, _owner.TitleTextStyle, null, twoCells));
  1020. // row 1
  1021. table.Rows.Add (
  1022. TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionInstructionText), null, _owner.InstructionTextStyle, null, twoCells));
  1023. // row 2
  1024. Literal UserNameLiteral = new Literal ();
  1025. UserNameLiteral.ID = "UserName";
  1026. table.Rows.Add (
  1027. TemplateUtils.CreateRow (new LiteralControl (_owner.UserNameLabelText), UserNameLiteral, _owner.LabelStyle, _owner.LabelStyle, twoCells));
  1028. // row 3
  1029. Literal QuestionLiteral = new Literal ();
  1030. QuestionLiteral.ID = "Question";
  1031. table.Rows.Add (
  1032. TemplateUtils.CreateRow (new LiteralControl (_owner.QuestionLabelText), QuestionLiteral, _owner.LabelStyle, _owner.LabelStyle, twoCells));
  1033. // row 5
  1034. TextBox AnswerTextBox = new TextBox ();
  1035. AnswerTextBox.ID = "Answer";
  1036. AnswerTextBox.ApplyStyle (_owner.TextBoxStyle);
  1037. Label AnswerLabel = new Label ();
  1038. AnswerLabel.ID = "AnswerLabel";
  1039. AnswerLabel.AssociatedControlID = "Answer";
  1040. AnswerLabel.Text = _owner.AnswerLabelText;
  1041. AnswerLabel.ApplyStyle (_owner.LabelStyle);
  1042. RequiredFieldValidator AnswerRequired = new RequiredFieldValidator ();
  1043. AnswerRequired.ID = "AnswerRequired";
  1044. AnswerRequired.ControlToValidate = "Answer";
  1045. AnswerRequired.ErrorMessage = _owner.AnswerRequiredErrorMessage;
  1046. AnswerRequired.ToolTip = _owner.AnswerRequiredErrorMessage;
  1047. AnswerRequired.Text = "*";
  1048. AnswerRequired.ValidationGroup = _owner.ID;
  1049. AnswerRequired.ApplyStyle (_owner.ValidatorTextStyle);
  1050. if (twoCells) {
  1051. TableRow row = TemplateUtils.CreateRow (AnswerLabel, AnswerTextBox, null, null, twoCells);
  1052. row.Cells [1].Controls.Add (AnswerRequired);
  1053. table.Rows.Add (row);
  1054. }
  1055. else {
  1056. table.Rows.Add (TemplateUtils.CreateRow (AnswerLabel, null, null, null, twoCells));
  1057. TableRow row = TemplateUtils.CreateRow (AnswerTextBox, null, null, null, twoCells);
  1058. row.Cells [0].Controls.Add (AnswerRequired);
  1059. table.Rows.Add (row);
  1060. }
  1061. // row 6
  1062. Literal FailureText = new Literal ();
  1063. FailureText.ID = "FailureText";
  1064. if (_owner.FailureTextStyle.ForeColor.IsEmpty)
  1065. _owner.FailureTextStyle.ForeColor = System.Drawing.Color.Red;
  1066. table.Rows.Add (TemplateUtils.CreateRow (FailureText, null, _owner.FailureTextStyle, null, twoCells));
  1067. // row 7
  1068. WebControl SubmitButton = null;
  1069. switch (_owner.SubmitButtonType) {
  1070. case ButtonType.Button:
  1071. SubmitButton = new Button ();
  1072. break;
  1073. case ButtonType.Image:
  1074. SubmitButton = new ImageButton ();
  1075. break;
  1076. case ButtonType.Link:
  1077. SubmitButton = new LinkButton ();
  1078. break;
  1079. }
  1080. SubmitButton.ID = "SubmitButton";
  1081. SubmitButton.ApplyStyle (_owner.SubmitButtonStyle);
  1082. ((IButtonControl) SubmitButton).CommandName = PasswordRecovery.SubmitButtonCommandName;
  1083. ((IButtonControl) SubmitButton).Text = _owner.SubmitButtonText;
  1084. ((IButtonControl) SubmitButton).ValidationGroup = _owner.ID;
  1085. TableRow buttonRow = TemplateUtils.CreateRow (SubmitButton, null, null, null, twoCells);
  1086. buttonRow.Cells [0].HorizontalAlign = HorizontalAlign.Right;
  1087. table.Rows.Add (buttonRow);
  1088. // row 8
  1089. table.Rows.Add (
  1090. TemplateUtils.CreateHelpRow (
  1091. _owner.HelpPageUrl, _owner.HelpPageText, _owner.HelpPageIconUrl, _owner.HyperLinkStyle, twoCells));
  1092. container.Controls.Add (table);
  1093. }
  1094. }
  1095. sealed class SuccessDefaultTemplate : ITemplate
  1096. {
  1097. readonly PasswordRecovery _owner = null;
  1098. public SuccessDefaultTemplate (PasswordRecovery _owner)
  1099. {
  1100. this._owner = _owner;
  1101. }
  1102. public void InstantiateIn (Control container)
  1103. {
  1104. Table table = new Table ();
  1105. table.CellPadding = 0;
  1106. bool twoCells = _owner.TextLayout == LoginTextLayout.TextOnLeft;
  1107. // row 0
  1108. table.Rows.Add (
  1109. TemplateUtils.CreateRow (new LiteralControl (_owner.SuccessText), null, _owner.SuccessTextStyle, null, twoCells));
  1110. container.Controls.Add (table);
  1111. }
  1112. }
  1113. enum PasswordReciveryStep
  1114. {
  1115. StepUserName,
  1116. StepAnswer,
  1117. StepSuccess,
  1118. }
  1119. }
  1120. }
  1121. #endif