2009-02-18 13:15:07 +01:00
|
|
|
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
|
2009-03-15 08:07:09 +01:00
|
|
|
Date: 2009-03-15
|
|
|
|
Initial Package Version: 0.2.1
|
2009-02-18 13:15:07 +01:00
|
|
|
Origin: http://trac-hacks.org/wiki/RegistrationConfirmationPatch
|
|
|
|
Upstream Status: unknown
|
2009-03-15 08:07:09 +01:00
|
|
|
Description: This is a patch for AccountManagerPlugin that adds an
|
|
|
|
IRegistrationConfirmation extension point that enables pluggable
|
|
|
|
verifications for new user registration.
|
2009-02-18 13:15:07 +01:00
|
|
|
|
|
|
|
diff -Naur trac-acct_mgr-0.2.1.orig/acct_mgr/api.py trac-acct_mgr-0.2.1/acct_mgr/api.py
|
2009-03-15 08:07:09 +01:00
|
|
|
--- trac-acct_mgr-0.2.1.orig/acct_mgr/api.py 2009-03-15 06:40:44.875670135 +0000
|
|
|
|
+++ trac-acct_mgr-0.2.1/acct_mgr/api.py 2009-03-15 06:41:38.225188601 +0000
|
2009-02-18 13:15:07 +01:00
|
|
|
@@ -77,6 +77,19 @@
|
|
|
|
"""User deleted
|
|
|
|
"""
|
|
|
|
|
|
|
|
+class IRegistrationConfirmation(Interface):
|
|
|
|
+ """An interface for receiving notification before and after the new user
|
|
|
|
+ registration form has been submitted.
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
+ def pre_registration(self, req):
|
|
|
|
+ """Returns the markup to be added to the registration form
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
+ def verify_registration(self, req):
|
|
|
|
+ """Returns an error message if confirmation fails, or None on success
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
class AccountManager(Component):
|
|
|
|
"""The AccountManager component handles all user account management methods
|
|
|
|
provided by the IPasswordStore interface.
|
|
|
|
diff -Naur trac-acct_mgr-0.2.1.orig/acct_mgr/templates/register.html trac-acct_mgr-0.2.1/acct_mgr/templates/register.html
|
2009-03-15 08:07:09 +01:00
|
|
|
--- trac-acct_mgr-0.2.1.orig/acct_mgr/templates/register.html 2009-03-15 06:40:44.873359012 +0000
|
|
|
|
+++ trac-acct_mgr-0.2.1/acct_mgr/templates/register.html 2009-03-15 06:41:38.227503636 +0000
|
2009-02-18 13:15:07 +01:00
|
|
|
@@ -43,6 +43,11 @@
|
|
|
|
class="textwidget" size="20" />
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
+ <py:if test="extra_required_content">
|
|
|
|
+ <div>
|
|
|
|
+ ${Markup(extra_required_content)}
|
|
|
|
+ </div>
|
|
|
|
+ </py:if>
|
|
|
|
</fieldset>
|
|
|
|
<fieldset>
|
|
|
|
<legend>Optional</legend>
|
|
|
|
diff -Naur trac-acct_mgr-0.2.1.orig/acct_mgr/web_ui.py trac-acct_mgr-0.2.1/acct_mgr/web_ui.py
|
2009-03-15 08:07:09 +01:00
|
|
|
--- trac-acct_mgr-0.2.1.orig/acct_mgr/web_ui.py 2009-03-15 06:40:44.875670135 +0000
|
|
|
|
+++ trac-acct_mgr-0.2.1/acct_mgr/web_ui.py 2009-03-15 06:59:06.581876742 +0000
|
|
|
|
@@ -394,19 +394,28 @@
|
2009-02-18 13:15:07 +01:00
|
|
|
'name' : None,
|
|
|
|
'email' : None,
|
|
|
|
},
|
2009-03-15 08:07:09 +01:00
|
|
|
+ 'extra_required_content' : self._get_extra_content(req),
|
2009-02-18 13:15:07 +01:00
|
|
|
}
|
|
|
|
+ error = None
|
|
|
|
if req.method == 'POST' and action == 'create':
|
|
|
|
- try:
|
|
|
|
- _create_user(req, self.env)
|
|
|
|
- except TracError, e:
|
|
|
|
- data['registration_error'] = e.message
|
2009-03-15 08:07:09 +01:00
|
|
|
- formdata = getattr(e, 'acctmgr', None)
|
|
|
|
- if formdata:
|
|
|
|
- data['acctmgr'] = formdata
|
|
|
|
- else:
|
|
|
|
- raise e
|
|
|
|
- else:
|
|
|
|
- req.redirect(req.href.login())
|
2009-02-18 13:15:07 +01:00
|
|
|
+ for listener in self.listeners:
|
|
|
|
+ error = listener.verify_registration(req)
|
|
|
|
+ if error is not None:
|
|
|
|
+ break
|
|
|
|
+ data['registration_error'] = error
|
|
|
|
+ if error is None:
|
2009-03-15 08:07:09 +01:00
|
|
|
+ try:
|
|
|
|
+ _create_user(req, self.env)
|
|
|
|
+ except TracError, e:
|
|
|
|
+ data['registration_error'] = e.message
|
|
|
|
+ formdata = getattr(e, 'acctmgr', None)
|
|
|
|
+ if formdata:
|
|
|
|
+ data['acctmgr'] = formdata
|
|
|
|
+ else:
|
|
|
|
+ raise e
|
|
|
|
+ else:
|
|
|
|
+ req.redirect(req.href.login())
|
2009-02-18 13:15:07 +01:00
|
|
|
+
|
|
|
|
data['reset_password_enabled'] = \
|
|
|
|
(self.env.is_component_enabled(AccountModule)
|
|
|
|
and NotificationSystem(self.env).smtp_enabled)
|
2009-03-15 08:07:09 +01:00
|
|
|
@@ -414,6 +423,14 @@
|
2009-02-18 13:15:07 +01:00
|
|
|
return 'register.html', data, None
|
|
|
|
|
2009-03-15 08:07:09 +01:00
|
|
|
|
|
|
|
+ def _get_extra_content(self, req):
|
|
|
|
+ ret = ""
|
|
|
|
+ for listener in self.listeners:
|
|
|
|
+ response = listener.pre_registration(req)
|
|
|
|
+ if response is not None:
|
|
|
|
+ ret += response
|
|
|
|
+ return ret
|
|
|
|
+
|
2009-02-18 13:15:07 +01:00
|
|
|
# ITemplateProvider
|
|
|
|
|
|
|
|
def get_htdocs_dirs(self):
|