MembershipUser.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. //
  2. // System.Web.Security.MembershipUser
  3. //
  4. // Authors:
  5. // Ben Maurer ([email protected])
  6. //
  7. // (C) 2003 Ben Maurer
  8. //
  9. #if NET_1_2
  10. namespace System.Web.Security {
  11. public class MembershipUser {
  12. protected MembershipUser ()
  13. {
  14. }
  15. public MembershipUser (IMembershipProvider provider, string name, string email,
  16. string passwordQuestion, string comment, bool isApproved,
  17. DateTime creationDate, DateTime lastLoginDate, DateTime lastActivityDate,
  18. DateTime lastPasswordChangedDate)
  19. {
  20. this.provider = provider;
  21. this.name = name;
  22. this.email = email;
  23. this.passwordQuestion = passwordQuestion;
  24. this.comment = comment;
  25. this.isApproved = isApproved;
  26. this.creationDate = creationDate;
  27. this.lastLoginDate = lastLoginDate;
  28. this.lastActivityDate = lastActivityDate;
  29. this.lastPasswordChangedDate = lastPasswordChangedDate;
  30. }
  31. public virtual bool ChangePassword (string oldPassword, string newPassword)
  32. {
  33. bool success = Provider.ChangePassword (Username, oldPassword, newPassword);
  34. if (success)
  35. LastPasswordChangedDate = DateTime.Now;
  36. return success;
  37. }
  38. public virtual bool ChangePasswordQuestionAndAnswer (string password, string newPasswordQuestion, string newPasswordAnswer)
  39. {
  40. bool success = Provider.ChangePasswordQuestionAndAnswer (Username, password, newPasswordQuestion, newPasswordAnswer);
  41. if (success)
  42. passwordQuestion = newPasswordQuestion;
  43. return success;
  44. }
  45. public virtual string GetPassword ()
  46. {
  47. return GetPassword (null);
  48. }
  49. public virtual string GetPassword (string answer)
  50. {
  51. return Provider.GetPassword (Username, answer);
  52. }
  53. public virtual string ResetPassword ()
  54. {
  55. return ResetPassword (null);
  56. }
  57. public virtual string ResetPassword (string answer)
  58. {
  59. string newPass = Provider.ResetPassword (Username, answer);
  60. if (newPass != null)
  61. LastPasswordChangedDate = DateTime.Now;
  62. return newPass;
  63. }
  64. public virtual string Comment {
  65. get { return comment; }
  66. set { comment = value; }
  67. }
  68. public virtual DateTime CreationDate {
  69. get { return creationDate; }
  70. set { creationDate = value; }
  71. }
  72. public virtual string Email {
  73. get { return email; }
  74. set { email = value; }
  75. }
  76. public virtual bool IsApproved {
  77. get { return isApproved; }
  78. set { isApproved = value; }
  79. }
  80. [MonoTODO]
  81. public bool IsOnline {
  82. get { throw new NotImplementedException (); }
  83. }
  84. public virtual DateTime LastActivityDate {
  85. get { return lastActivityDate; }
  86. set { lastActivityDate = value; }
  87. }
  88. public virtual DateTime LastLoginDate {
  89. get { return lastLoginDate; }
  90. set { lastLoginDate = value; }
  91. }
  92. public virtual DateTime LastPasswordChangedDate {
  93. get { return lastPasswordChangedDate; }
  94. set { lastPasswordChangedDate = value; }
  95. }
  96. public virtual string PasswordQuestion {
  97. get { return passwordQuestion; }
  98. }
  99. public virtual IMembershipProvider Provider {
  100. get { return provider; }
  101. }
  102. public virtual string Username {
  103. get { return name; }
  104. }
  105. IMembershipProvider provider;
  106. string name;
  107. string email;
  108. string passwordQuestion;
  109. string comment;
  110. bool isApproved;
  111. DateTime creationDate;
  112. DateTime lastLoginDate;
  113. DateTime lastActivityDate;
  114. DateTime lastPasswordChangedDate;
  115. }
  116. }
  117. #endif