6b4c6bbb6e050516bdeaa2d69d8a5bd38bf79a46
[openafs-wiki.git] / TWiki / TWikiUsersPasswordDotPm.mdwn
1 # <a name="Package &lt;code&gt;TWiki::Users::Password="></a> Package =TWiki::Users::Password
2
3 Base class of all password handlers. Default behaviour is no passwords, so anyone can be anyone they like.
4
5 The methods of this class should be overridded by subclasses that want to implement other password handling methods.
6
7 <div>
8   <ul>
9     <li><a href="#Package =TWiki::Users::Password="> Package TWiki::Users::Password</a><ul>
10         <li><a href="#ClassMethod <strong>new</strong> ($session) ->"> ClassMethod new <tt>($session) -&gt; $object</tt></a></li>
11         <li><a href="#ObjectMethod <strong>fetchPass</strong> ($login"> ObjectMethod fetchPass <tt>($login) -&gt; $passwordE</tt></a></li>
12         <li><a href="#ObjectMethod <strong>checkPassword</strong> ($u"> ObjectMethod checkPassword <tt>($user,$passwordU) -&gt; $boolean</tt></a></li>
13         <li><a href="#ObjectMethod <strong>deleteUser</strong> ($user"> ObjectMethod deleteUser <tt>($user) -&gt; $boolean</tt></a></li>
14         <li><a href="#ObjectMethod <strong>passwd</strong> ($user,$ne"> ObjectMethod passwd <tt>($user,$newPassU,$oldPassU) -&gt; $boolean</tt></a></li>
15         <li><a href="#encrypt( $user, $passwordU, $fre"> encrypt( $user, $passwordU, $fresh ) -&gt; $passwordE</a></li>
16         <li><a href="#ObjectMethod <strong>error</strong> () -> $stri"> ObjectMethod error <tt>() -&gt; $string</tt></a></li>
17         <li><a href="#ObjectMethod <strong>getEmails</strong> ($user)"> ObjectMethod getEmails <tt>($user) -&gt; @emails</tt></a></li>
18         <li><a href="#ObjectMethod <strong>setEmails</strong> ($user,"> ObjectMethod setEmails <tt>($user,@emails)</tt></a></li>
19       </ul>
20     </li>
21   </ul>
22 </div>
23
24 ## <a name="ClassMethod &lt;strong&gt;new&lt;/strong&gt; ($session) - $"></a> [[ClassMethod]] **new** `($session) -> $object`
25
26 Constructs a new password handler of this type, referring to $session for any required TWiki services.
27
28 ## <a name="ObjectMethod &lt;strong&gt;fetchPass&lt;/strong&gt; ($login"></a> [[ObjectMethod]] **fetchPass** `($login) -> $passwordE`
29
30 Implements TWiki::Password
31
32 Returns encrypted password if succeeds. Returns 0 if login is invalid. Returns undef otherwise.
33
34 ## <a name="ObjectMethod &lt;strong&gt;checkPassword&lt;/strong&gt; ($u"></a> [[ObjectMethod]] **checkPassword** `($user,$passwordU) -> $boolean`
35
36 Finds if the password is valid for the given login.
37
38 Returns 1 on success, undef on failure.
39
40 ## <a name="ObjectMethod &lt;strong&gt;deleteUser&lt;/strong&gt; ($user"></a> [[ObjectMethod]] **deleteUser** `($user) -> $boolean`
41
42 Delete users entry.
43
44 Returns 1 on success, undef on failure.
45
46 ## <a name="ObjectMethod &lt;strong&gt;passwd&lt;/strong&gt; ($user,$ne"></a> [[ObjectMethod]] **passwd** `($user,$newPassU,$oldPassU) -> $boolean`
47
48 If the $oldPassU is undef, it will try to add the user, failing if they are already there.
49
50 If the $oldPassU matches matches the login's password, then it will replace it with $newPassU.
51
52 If $oldPassU is not correct and not 1, will return 0.
53
54 If $oldPassU is 1, will force the change irrespective of the existing password, adding the user if necessary.
55
56 Otherwise returns 1 on success, undef on failure.
57
58 ## <a name="encrypt( $user, $passwordU, $fre"></a> encrypt( $user, $passwordU, $fresh ) -&gt; $passwordE
59
60 Will return an encrypted password. Repeated calls to encrypt with the same user/passU will return the same passE.
61
62 However if the passU is changed, and subsequently changed _back_ to the old user/passU pair, then the old passE is no longer valid.
63
64 If $fresh is true, then a new password not based on any pre-existing salt will be used. Set this if you are generating a completely new password.
65
66 ## <a name="ObjectMethod &lt;strong&gt;error&lt;/strong&gt; () - $strin"></a> [[ObjectMethod]] **error** `() -> $string`
67
68 Return any error raised by the last method call, or undef if the last method call succeeded.
69
70 ## <a name="ObjectMethod &lt;strong&gt;getEmails&lt;/strong&gt; ($user)"></a> [[ObjectMethod]] **getEmails** `($user) -> @emails`
71
72 Fetch the email address(es) for the given username. Default behaviour is to look up the users' personal topic.
73
74 ## <a name="ObjectMethod &lt;strong&gt;setEmails&lt;/strong&gt; ($user,"></a> [[ObjectMethod]] **setEmails** `($user,@emails)`
75
76 Set the email address(es) for the given username in the user topic.