www-apps/trac-acct_mgr: add IRegistrationConfirmation patch

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/linamh@782 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
geos_one 2009-02-18 12:15:07 +00:00
parent 685d6335fc
commit d32adcdd80
3 changed files with 132 additions and 2 deletions

View File

@ -1,7 +1,11 @@
# ChangeLog for www-apps/trac-acct_mgr # ChangeLog for www-apps/trac-acct_mgr
# Copyright 1999-2008 Gentoo Foundation; Distributed under the GPL v2 # Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
# $Header: $ # $Header: $
18 Feb 2009; Mario Fetka <mario.fetka@gmail.com>
+files/RegistrationConfirmationPatch.diff:
add IRegistrationConfirmation patch
23 Nov 2008; Mario Fetka <mario.fetka@gmail.com> 23 Nov 2008; Mario Fetka <mario.fetka@gmail.com>
trac-acct_mgr-0.2.1.ebuild: trac-acct_mgr-0.2.1.ebuild:
correct trac dependency correct trac dependency

View File

@ -1,5 +1,5 @@
AUX RegistrationConfirmationPatch.diff 4616 RMD160 db685311cf66aa0b56fef2f6609bf66b19fcc0aa SHA1 cc8994159967e559281cd35587b7813f8772d66e SHA256 ca5804ff9f94e8098b030d120286ee2a9e8ddf7c993a246e501d2ca4d37e3646 AUX RegistrationConfirmationPatch.diff 4616 RMD160 db685311cf66aa0b56fef2f6609bf66b19fcc0aa SHA1 cc8994159967e559281cd35587b7813f8772d66e SHA256 ca5804ff9f94e8098b030d120286ee2a9e8ddf7c993a246e501d2ca4d37e3646
EBUILD trac-acct_mgr-0.1.3.ebuild 1214 RMD160 08c61116b34731a9204414a8801df2ed49327e61 SHA1 366ed27ec819f45a352573b3029ad79d84ece486 SHA256 dbcaa0bbb198ee2c4bb8d354dce62faabe36c823bfda827daf16fb87ec2c9b2c EBUILD trac-acct_mgr-0.1.3.ebuild 1214 RMD160 08c61116b34731a9204414a8801df2ed49327e61 SHA1 366ed27ec819f45a352573b3029ad79d84ece486 SHA256 dbcaa0bbb198ee2c4bb8d354dce62faabe36c823bfda827daf16fb87ec2c9b2c
EBUILD trac-acct_mgr-0.2.1.ebuild 1452 RMD160 d7a6f2c4383b7d8e20f1436d207f42f3f12ec216 SHA1 e9b155b3b1624f01fcca7900b732ae79a142e92e SHA256 db959f598775b0b3ddfc88aec6e235e27a70785dbd56e9644692410c38e6902e EBUILD trac-acct_mgr-0.2.1.ebuild 1452 RMD160 d7a6f2c4383b7d8e20f1436d207f42f3f12ec216 SHA1 e9b155b3b1624f01fcca7900b732ae79a142e92e SHA256 db959f598775b0b3ddfc88aec6e235e27a70785dbd56e9644692410c38e6902e
MISC ChangeLog 534 RMD160 cc0a5580bff4d55a5cb619d62c5e7b5703ceec5c SHA1 11b374a06caaa193d7ae5a520e5c7933b7722352 SHA256 f85cc9d037e0a24612a5590af9408c3c7d21954f8a999673f583d2ea93806f71 MISC ChangeLog 669 RMD160 62c7ea24628f6f712e817bde78429e81a5460211 SHA1 c6d07fb69a6fab1550cbad3da08d697badd5af7a SHA256 98f7efd8d06fe16349834bebf3b29b1f9e74eafd440aa2859ccc2e7decf00973
MISC metadata.xml 170 RMD160 645927a396fdc21cdeb089fe42c5397332420ea6 SHA1 ac7f48a14fec325926f9ce1be8fbf1f311b4f2e4 SHA256 d797a2ec6f9dc516c9f9c1a758ee87ad3e8c43101b5dc76c2f872d5bd4639b42 MISC metadata.xml 170 RMD160 645927a396fdc21cdeb089fe42c5397332420ea6 SHA1 ac7f48a14fec325926f9ce1be8fbf1f311b4f2e4 SHA256 d797a2ec6f9dc516c9f9c1a758ee87ad3e8c43101b5dc76c2f872d5bd4639b42

View File

@ -0,0 +1,126 @@
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
Date: 2009-02-18
Initial Package Version: unknown
Origin: http://trac-hacks.org/wiki/RegistrationConfirmationPatch
Upstream Status: unknown
Description: This is a patch for AccountManagerPlugin that adds an
IRegistrationConfirmation extension point that enables pluggable
verifications for new user registration.
diff -Naur trac-acct_mgr-0.2.1.orig/acct_mgr/api.py trac-acct_mgr-0.2.1/acct_mgr/api.py
--- trac-acct_mgr-0.2.1.orig/acct_mgr/api.py 2009-02-18 09:10:33.000000000 +0000
+++ trac-acct_mgr-0.2.1/acct_mgr/api.py 2009-02-18 09:42:33.254276668 +0000
@@ -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
--- trac-acct_mgr-0.2.1.orig/acct_mgr/templates/register.html 2009-02-18 09:10:33.000000000 +0000
+++ trac-acct_mgr-0.2.1/acct_mgr/templates/register.html 2009-02-18 09:42:33.256586814 +0000
@@ -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
--- trac-acct_mgr-0.2.1.orig/acct_mgr/web_ui.py 2009-02-18 09:10:33.000000000 +0000
+++ trac-acct_mgr-0.2.1/acct_mgr/web_ui.py 2009-02-18 09:45:45.904094348 +0000
@@ -27,6 +27,7 @@
from genshi.builder import tag
from api import AccountManager
+from api import IRegistrationConfirmation
from acct_mgr.util import urandom
def _create_user(req, env, check_permissions=True):
@@ -351,6 +352,8 @@
implements(INavigationContributor, IRequestHandler, ITemplateProvider)
+ listeners = ExtensionPoint(IRegistrationConfirmation)
+
def __init__(self):
self._enable_check(log=True)
@@ -394,26 +397,42 @@
'name' : None,
'email' : None,
},
+ 'extra_required_content' : self._get_extra_content(req)
}
+ error = None
if req.method == 'POST' and action == 'create':
- try:
- _create_user(req, self.env)
- except TracError, e:
- data['registration_error'] = e.message
+ for listener in self.listeners:
+ error = listener.verify_registration(req)
+ if error is not None:
+ break
+ data['registration_error'] = error
+ if error is None:
+ 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())
+ else:
+ req.redirect(req.href.login())
+
data['reset_password_enabled'] = \
(self.env.is_component_enabled(AccountModule)
and NotificationSystem(self.env).smtp_enabled)
return 'register.html', data, None
-
+ 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
+
# ITemplateProvider
def get_htdocs_dirs(self):
@@ -427,7 +446,7 @@
ClearSilver templates.
"""
from pkg_resources import resource_filename
- return [resource_filename(__name__, 'templates')]
+ return [resource_filename(__name__, 'templates')]
def if_enabled(func):