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