MembershipUser.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // System.Web.Security.MembershipUser
  3. //
  4. // Authors:
  5. // Ben Maurer ([email protected])
  6. //
  7. // (C) 2003 Ben Maurer
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. #if NET_2_0
  30. namespace System.Web.Security {
  31. public class MembershipUser {
  32. protected MembershipUser ()
  33. {
  34. }
  35. public MembershipUser (MembershipProvider provider, string name, string email,
  36. string passwordQuestion, string comment, bool isApproved,
  37. DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate,
  38. DateTime lastPasswordChangedDate)
  39. {
  40. this.provider = provider;
  41. this.name = name;
  42. this.email = email;
  43. this.passwordQuestion = passwordQuestion;
  44. this.comment = comment;
  45. this.isApproved = isApproved;
  46. this.creationDate = creationDate;
  47. this.lastLoginDate = lastLoginDate;
  48. this.lastActivityDate = lastActivityDate;
  49. this.lastPasswordChangedDate = lastPasswordChangedDate;
  50. }
  51. public virtual bool ChangePassword (string oldPassword, string newPassword)
  52. {
  53. bool success = Provider.ChangePassword (Username, oldPassword, newPassword);
  54. if (success)
  55. LastPasswordChangedDate = DateTime.Now;
  56. return success;
  57. }
  58. public virtual bool ChangePasswordQuestionAndAnswer (string password, string newPasswordQuestion, string newPasswordAnswer)
  59. {
  60. bool success = Provider.ChangePasswordQuestionAndAnswer (Username, password, newPasswordQuestion, newPasswordAnswer);
  61. if (success)
  62. passwordQuestion = newPasswordQuestion;
  63. return success;
  64. }
  65. public virtual string GetPassword ()
  66. {
  67. return GetPassword (null);
  68. }
  69. public virtual string GetPassword (string answer)
  70. {
  71. return Provider.GetPassword (Username, answer);
  72. }
  73. public virtual string ResetPassword ()
  74. {
  75. return ResetPassword (null);
  76. }
  77. public virtual string ResetPassword (string answer)
  78. {
  79. string newPass = Provider.ResetPassword (Username, answer);
  80. if (newPass != null)
  81. LastPasswordChangedDate = DateTime.Now;
  82. return newPass;
  83. }
  84. public virtual string Comment {
  85. get { return comment; }
  86. set { comment = value; }
  87. }
  88. public virtual DateTime CreationDate {
  89. get { return creationDate; }
  90. set { creationDate = value; }
  91. }
  92. public virtual string Email {
  93. get { return email; }
  94. set { email = value; }
  95. }
  96. public virtual bool IsApproved {
  97. get { return isApproved; }
  98. set { isApproved = value; }
  99. }
  100. [MonoTODO]
  101. public bool IsOnline {
  102. get { throw new NotImplementedException (); }
  103. }
  104. public virtual DateTime LastActivityDate {
  105. get { return lastActivityDate; }
  106. set { lastActivityDate = value; }
  107. }
  108. public virtual DateTime LastLoginDate {
  109. get { return lastLoginDate; }
  110. set { lastLoginDate = value; }
  111. }
  112. public virtual DateTime LastPasswordChangedDate {
  113. get { return lastPasswordChangedDate; }
  114. set { lastPasswordChangedDate = value; }
  115. }
  116. public virtual string PasswordQuestion {
  117. get { return passwordQuestion; }
  118. }
  119. public virtual MembershipProvider Provider {
  120. get { return provider; }
  121. }
  122. public virtual string Username {
  123. get { return name; }
  124. }
  125. MembershipProvider provider;
  126. string name;
  127. string email;
  128. string passwordQuestion;
  129. string comment;
  130. bool isApproved;
  131. DateTime creationDate;
  132. DateTime lastLoginDate;
  133. DateTime lastActivityDate;
  134. DateTime lastPasswordChangedDate;
  135. }
  136. }
  137. #endif