annotate MoinMoin/action/recoverpass.py @ 2967:a310264ad186

Added a few add_msg calls (by Federico Lorenzi).
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Mon, 24 Dec 2007 00:16:48 +0100
parents 388204baf00f
children 15d744f727c9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
2 """
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
3 MoinMoin - create account action
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
4
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
5 @copyright: 2007 MoinMoin:JohannesBerg
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
6 @license: GNU GPL, see COPYING for details.
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
7 """
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
8
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
9 from MoinMoin import user, wikiutil
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
10 from MoinMoin.Page import Page
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
11 from MoinMoin.widget import html
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
12
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
13 def _do_recover(request):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
14 _ = request.getText
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
15 form = request.form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
16 if not request.cfg.mail_enabled:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
17 return _("""This wiki is not enabled for mail processing.
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
18 Contact the owner of the wiki, who can enable email.""")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
19 try:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
20 email = wikiutil.clean_input(form['email'][0].lower())
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
21 except KeyError:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
22 return _("Please provide a valid email address!")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
23
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
24 u = user.get_by_email_address(request, email)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
25 if u:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
26 msg = u.mailAccountData()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
27 return wikiutil.escape(msg)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
28
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
29 return _("Found no account matching the given email address '%(email)s'!") % {'email': email}
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
30
2366
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
31 def _create_form(request):
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
32 _ = request.getText
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
33 url = request.page.url(request)
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
34 ret = html.FORM(action=url)
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
35 ret.append(html.INPUT(type='hidden', name='action', value='recoverpass'))
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
36 lang_attr = request.theme.ui_lang_attr()
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
37 ret.append(html.Raw('<div class="userpref"%s>' % lang_attr))
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
38 tbl = html.TABLE(border="0")
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
39 ret.append(tbl)
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
40 ret.append(html.Raw('</div>'))
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
41
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
42 row = html.TR()
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
43 tbl.append(row)
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
44 row.append(html.TD().append(html.STRONG().append(html.Text(_("Email")))))
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
45 row.append(html.TD().append(html.INPUT(type="text", size="36",
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
46 name="email")))
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
47
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
48 row = html.TR()
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
49 tbl.append(row)
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
50 row.append(html.TD())
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
51 td = html.TD()
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
52 row.append(td)
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
53 td.append(html.INPUT(type="submit", name="account_sendmail",
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
54 value=_('Mail me my account data')))
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
55
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
56 return unicode(ret)
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
57
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
58
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
59 def execute(pagename, request):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
60 pagename = pagename
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
61 page = Page(request, pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
62 _ = request.getText
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
63 form = request.form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
64
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
65 submitted = form.get('account_sendmail', [''])[0]
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
66
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
67 if submitted: # user pressed create button
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
68 msg = _do_recover(request)
2967
a310264ad186 Added a few add_msg calls (by Federico Lorenzi).
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2725
diff changeset
69 request.theme.add_msg(msg, "dialog")
a310264ad186 Added a few add_msg calls (by Federico Lorenzi).
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2725
diff changeset
70 page.send_page()
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
71 else: # show create form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
72 request.emit_http_headers()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
73 request.theme.send_title(_("Lost password"), pagename=pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
74
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
75 request.write(request.formatter.startContent("content"))
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
76
2295
66cc37b8f297 recoverpass: give message about no mail right away
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
77 if not request.cfg.mail_enabled:
66cc37b8f297 recoverpass: give message about no mail right away
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
78 request.write(_("""This wiki is not enabled for mail processing.
66cc37b8f297 recoverpass: give message about no mail right away
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
79 Contact the owner of the wiki, who can enable email."""))
66cc37b8f297 recoverpass: give message about no mail right away
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
80 else:
2366
2f36b737022a split recoverpass form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2295
diff changeset
81 request.write(_create_form(request))
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
82
2295
66cc37b8f297 recoverpass: give message about no mail right away
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
83 request.write(_("""
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
84 == Recovering a lost password ==
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2366
diff changeset
85 <<BR>>
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
86 If you have forgotten your password, provide your email address and click on '''Mail me my account data'''.
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2366
diff changeset
87 <<BR>>
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
88 The email you get contains the encrypted password (so even if someone intercepts the mail, he won't know your REAL password). Just copy and paste it into the login mask into the password field and log in.
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
89 After logging in you should change your password."""))
2295
66cc37b8f297 recoverpass: give message about no mail right away
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
90
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
91 request.write(request.formatter.endContent())
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
92
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
93 request.theme.send_footer(pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
94 request.theme.send_closing_html()