annotate MoinMoin/action/newaccount.py @ 2888:78d96fd775ba

make newuser action check email using get_by_email_address Reimar pointed out that it is possible to register another email address with different case while get_by_email_address works case-insensitively which could result in security problems when retrieving the password
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 11 Oct 2007 11:27:10 +0200
parents f3e3ffa68a7f
children a310264ad186
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, util
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 import MoinMoin.events as events
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
13
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
14
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
15 _debug = False
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
16
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
17 def _create_user(request):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
18 _ = request.getText
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
19 form = request.form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
20
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
21 if request.request_method != 'POST':
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
22 return _("Use UserPreferences to change your settings or create an account.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
23 # Create user profile
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
24 theuser = user.User(request, auth_method="new-user")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
25
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
26 # Require non-empty name
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
27 try:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
28 theuser.name = form['name'][0]
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
29 except KeyError:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
30 return _("Empty user name. Please enter a user name.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
31
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
32 # Don't allow creating users with invalid names
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
33 if not user.isValidName(request, theuser.name):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
34 return _("""Invalid user name {{{'%s'}}}.
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
35 Name may contain any Unicode alpha numeric character, with optional one
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
36 space between words. Group page name is not allowed.""") % wikiutil.escape(theuser.name)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
37
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
38 # Name required to be unique. Check if name belong to another user.
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
39 if user.getUserId(request, theuser.name):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
40 return _("This user name already belongs to somebody else.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
41
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
42 # try to get the password and pw repeat
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
43 password = form.get('password', [''])[0]
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
44 password2 = form.get('password2', [''])[0]
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
45
2431
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
46 pw_checker = request.cfg.password_checker
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
47 if pw_checker:
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
48 pw_error = pw_checker(theuser.name, password)
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
49 if pw_error:
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
50 return _("Password not acceptable: %s") % pw_error
58260d360f5c password_checker (simple builtin test, optionally using python-crack lib)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2365
diff changeset
51
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
52 # Check if password is given and matches with password repeat
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
53 if password != password2:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
54 return _("Passwords don't match!")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
55 if not password:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
56 return _("Please specify a password!")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
57
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
58 # Encode password
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
59 if password and not password.startswith('{SHA}'):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
60 try:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
61 theuser.enc_password = user.encodePassword(password)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
62 except UnicodeError, err:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
63 # Should never happen
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
64 return "Can't encode password: %s" % str(err)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
65
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
66 # try to get the email, for new users it is required
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
67 email = wikiutil.clean_input(form.get('email', [''])[0])
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
68 theuser.email = email.strip()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
69 if not theuser.email:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
70 return _("Please provide your email address. If you lose your"
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
71 " login information, you can get it by email.")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
72
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
73 # Email should be unique - see also MoinMoin/script/accounts/moin_usercheck.py
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
74 if theuser.email and request.cfg.user_email_unique:
2888
78d96fd775ba make newuser action check email using get_by_email_address
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2493
diff changeset
75 if user.get_by_email_address(request, theuser.email):
78d96fd775ba make newuser action check email using get_by_email_address
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2493
diff changeset
76 return _("This email already belongs to somebody else.")
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
77
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
78 # save data
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
79 theuser.save()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
80
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
81 if form.has_key('create_and_mail'):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
82 theuser.mailAccountData()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
83
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
84 result = _("User account created! You can use this account to login now...")
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
85 if _debug:
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
86 result = result + util.dumpFormData(form)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
87 return result
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
88
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
89
2365
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
90 def _create_form(request):
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
91 _ = request.getText
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
92 url = request.page.url(request)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
93 ret = html.FORM(action=url)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
94 ret.append(html.INPUT(type='hidden', name='action', value='newaccount'))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
95 lang_attr = request.theme.ui_lang_attr()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
96 ret.append(html.Raw('<div class="userpref"%s>' % lang_attr))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
97 tbl = html.TABLE(border="0")
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
98 ret.append(tbl)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
99 ret.append(html.Raw('</div>'))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
100
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
101 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
102 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
103 row.append(html.TD().append(html.STRONG().append(
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
104 html.Text(_("Name")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
105 row.append(html.TD().append(html.INPUT(type="text", size="36",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
106 name="name")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
107
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
108 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
109 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
110 row.append(html.TD().append(html.STRONG().append(
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
111 html.Text(_("Password")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
112 row.append(html.TD().append(html.INPUT(type="password", size="36",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
113 name="password")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
114
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
115 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
116 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
117 row.append(html.TD().append(html.STRONG().append(
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
118 html.Text(_("Password repeat")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
119 row.append(html.TD().append(html.INPUT(type="password", size="36",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
120 name="password2")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
121
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
122 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
123 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
124 row.append(html.TD().append(html.STRONG().append(html.Text(_("Email")))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
125 row.append(html.TD().append(html.INPUT(type="text", size="36",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
126 name="email")))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
127
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
128 row = html.TR()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
129 tbl.append(row)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
130 row.append(html.TD())
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
131 td = html.TD()
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
132 row.append(td)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
133 td.append(html.INPUT(type="submit", name="create_only",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
134 value=_('Create Profile')))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
135 if request.cfg.mail_enabled:
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
136 td.append(html.Text(' '))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
137 td.append(html.INPUT(type="submit", name="create_and_mail",
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
138 value="%s + %s" % (_('Create Profile'),
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
139 _('Email'))))
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
140
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
141 return unicode(ret)
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
142
2294
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
143 def execute(pagename, request):
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
144 pagename = pagename
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
145 page = Page(request, pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
146 _ = request.getText
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
147 form = request.form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
148
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
149 submitted = form.has_key('create_only') or form.has_key('create_and_mail')
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
150
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
151 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
152 error = _create_user(request)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
153 return page.send_page(msg=error)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
154 else: # show create form
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
155 request.emit_http_headers()
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
156 request.theme.send_title(_("Create Account"), pagename=pagename)
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
157
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
158 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
159
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
160 # THIS IS A BIG HACK. IT NEEDS TO BE CLEANED UP
2365
b9feee61d28e split newaccount form from prefs
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 2294
diff changeset
161 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
162
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
163 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
164
22749e92a461 new userprefs handling including plugins; todo: refactor prefs.py
Johannes Berg <johannes AT sipsolutions DOT net>
parents:
diff changeset
165 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
166 request.theme.send_closing_html()