source: main/waeup.sirp/trunk/src/waeup/sirp/users.txt @ 7169

Last change on this file since 7169 was 7169, checked in by Henrik Bettermann, 13 years ago

Put all user component related stuff into the authentication module to avoid errors due to circular imports. The users module now only contains the usercontainer components.

File size: 1.5 KB
Line 
1User container for the WAeUP portal
2***********************************
3
4.. :doctest:
5.. :layer: waeup.sirp.testing.WAeUPSIRPUnitTestLayer
6
7Before we can start, we need some password managers available:
8
9    >>> from zope.app.authentication.placelesssetup import (
10    ...   PlacelessSetup)
11    >>> PlacelessSetup().setUp()
12
13We can create a user container which will hold the useraccounts for
14us:
15
16    >>> from waeup.sirp.users import UserContainer
17    >>> myusers = UserContainer()
18
19We can add users, just by passing a name, a password, and (optionally)
20a title and a description:
21
22    >>> myusers.addUser('bob', 'bobssecret')
23
24Now, Bob is in the container:
25
26    >>> list(myusers)
27    [u'bob']
28
29We can get Bob's account:
30
31    >>> bob = myusers['bob']
32    >>> bob
33    <waeup.sirp.authentication.Account object at 0x...>
34
35    >>> bob.name
36    'bob'
37
38    >>> bob.title
39    'bob'
40
41    >>> bob.description
42    'bob'
43
44As we did not give a title nor description, the name was taken instead
45for these values. The password, however, is stored encoded:
46
47    >>> bob.password
48    '...15aca8166'
49
50Remark: that we can tell the last chars of the 'encrypted' password,
51means, that the encryption is broken or at least waeker as it should
52be.
53
54XXX: We could provide a stronger (correct) SHA encryption.
55
56We can delete users:
57
58    >>> myusers.delUser('alice')
59
60The container won't complain, although there is no ``alice`` stored
61yet. But we can really delete users:
62
63    >>> myusers.delUser('bob')
64    >>> list(myusers)
65    []
Note: See TracBrowser for help on using the repository browser.