Attachment 'login.py.patch'
Download 1 --- login_orig.py 2006-04-18 20:55:43.000000000 +0200
2 +++ login.py 2006-04-22 09:12:10.659497968 +0200
3 @@ -9,8 +9,8 @@
4 @copyright: 2006 by Thomas Waldmann
5 @license: GNU GPL, see COPYING for details.
6 """
7 -
8 -from MoinMoin import user, wikiutil, userform
9 +import time
10 +from MoinMoin import user, wikiutil, userform, auth
11 from MoinMoin.Page import Page
12
13 def execute(pagename, request):
14 @@ -36,6 +36,10 @@
15 if islogin: # user pressed login button
16 # Trying to login with a user name and a password
17 # Require valid user name
18 + expires = float(form.get('RememberFor', [''])[0])
19 + request.cfg.cookie_lifetime = expires
20 + auth.deleteCookie(request)
21 +
22 name = form.get('name', [''])[0]
23 if not user.isValidName(request, name):
24 error = _("""Invalid user name {{{'%s'}}}.
25 @@ -46,17 +50,30 @@
26 elif not user.getUserId(request, name):
27 error = _('Unknown user name: {{{"%s"}}}. Please enter'
28 ' user name and password.') % name
29 -
30 - # Require password
31 + # Require password
32 else:
33 password = form.get('password',[None])[0]
34 if not password:
35 error = _("Missing password. Please enter user name and"
36 " password.")
37 else:
38 + u = user.User(request, name=name, password=password,
39 + auth_method='login_userpassword')
40 + u.remember_me = 0 # is not need because of the kind of selection
41 + u.save()
42 + lifetime = int(request.cfg.cookie_lifetime * 3600)
43 + now = time.time()
44 + expires = now + lifetime
45 +
46 + cookie = auth.makeCookie(request, u.id, lifetime, expires)
47 + # Set cookie
48 + request.setHttpHeader(cookie)
49 + # IMPORTANT: Prevent caching of current page and cookie
50 + request.disableHttpCaching()
51 +
52 if not request.user.valid:
53 error = _("Sorry, wrong password.")
54 -
55 +
56 return self.page.send_page(request, msg=error)
57
58 else: # show login form
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.