[gen] Add param Config.activateForgotPassword to allow to disable this functionality for sites where the email of users may be unknown.

This commit is contained in:
Gaetan Delannay 2012-07-27 11:01:35 +02:00
parent b2e1e8c780
commit 47cd8ee277
5 changed files with 11 additions and 3 deletions

View file

@ -2894,6 +2894,8 @@ class Config:
# Language that will be used as a basis for translating to other # Language that will be used as a basis for translating to other
# languages. # languages.
self.sourceLanguage = 'en' self.sourceLanguage = 'en'
# Activate or not the button on home page for asking a new password
self.activateForgotPassword = True
# When using Ogone, place an instance of appy.gen.ogone.OgoneConfig in # When using Ogone, place an instance of appy.gen.ogone.OgoneConfig in
# the field below. # the field below.
self.ogone = None self.ogone = None

View file

@ -728,6 +728,7 @@ class ZopeGenerator(Generator):
repls['languageSelector'] = self.config.languageSelector repls['languageSelector'] = self.config.languageSelector
repls['sourceLanguage'] = self.config.sourceLanguage repls['sourceLanguage'] = self.config.sourceLanguage
repls['ogone'] = repr(self.config.ogone) repls['ogone'] = repr(self.config.ogone)
repls['activateForgotPassword'] = self.config.activateForgotPassword
self.copyFile('config.pyt', repls, destName='config.py') self.copyFile('config.pyt', repls, destName='config.py')
def generateInit(self): def generateInit(self):

View file

@ -113,6 +113,10 @@ class ToolMixin(BaseMixin):
page = self.REQUEST.get('ACTUAL_URL').split('/')[-1] page = self.REQUEST.get('ACTUAL_URL').split('/')[-1]
return page not in ('edit', 'query', 'search', 'do') return page not in ('edit', 'query', 'search', 'do')
def showForgotPassword(self):
'''We must show link "forgot password?" when the app requires it.'''
return self.getProductConfig().activateForgotPassword
def getLanguages(self): def getLanguages(self):
'''Returns the supported languages. First one is the default.''' '''Returns the supported languages. First one is the default.'''
return self.getProductConfig().languages return self.getProductConfig().languages

View file

@ -47,6 +47,7 @@ grantableRoles = [<!grRoles!>]
languages = [<!languages!>] languages = [<!languages!>]
languageSelector = <!languageSelector!> languageSelector = <!languageSelector!>
sourceLanguage = '<!sourceLanguage!>' sourceLanguage = '<!sourceLanguage!>'
activateForgotPassword = <!activateForgotPassword!>
ogone = <!ogone!> ogone = <!ogone!>
# When Zope is starting or runs in test mode, there is no request object. We # When Zope is starting or runs in test mode, there is no request object. We

View file

@ -97,8 +97,8 @@
</div> </div>
</form> </form>
</div> </div>
<tal:comment replace="nothing">Popup for reinitialing the password</tal:comment> <tal:comment replace="nothing">Popup for reinitializing the password</tal:comment>
<div id="askPasswordReinitPopup" class="popup" tal:condition="isAnon"> <div id="askPasswordReinitPopup" class="popup" tal:condition="python: isAnon and tool.showForgotPassword()">
<form id="askPasswordReinitForm" method="post" <form id="askPasswordReinitForm" method="post"
tal:attributes="action python: tool.absolute_url() + '/askPasswordReinit'"> tal:attributes="action python: tool.absolute_url() + '/askPasswordReinit'">
<div align="center"> <div align="center">
@ -141,7 +141,7 @@
tal:define="label python: _('app_connect')" tal:attributes="value label; alt label;"/> tal:define="label python: _('app_connect')" tal:attributes="value label; alt label;"/>
</form> </form>
</td> </td>
<td class="lostPassword"> <td class="lostPassword" tal:condition="tool/showForgotPassword">
<a href="javascript: openPopup('askPasswordReinitPopup')" <a href="javascript: openPopup('askPasswordReinitPopup')"
tal:content="python: _('forgot_password')"></a></td> tal:content="python: _('forgot_password')"></a></td>
</tr> </tr>