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