Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Commit

Permalink
Read use_email_as_login from registry instead of portal properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jcerjak committed Jan 25, 2015
1 parent 3b81f12 commit 5a9bacc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,10 @@ Changelog
2.1.2 (unreleased)
------------------

- Read ``use_email_as_login`` setting from the registry instead of portal
properties (see https://github.com/plone/Products.CMFPlone/issues/216).
[jcerjak]

- Amend browser.txt test to the new p.a.registry-based control panels
(Plone 5 only).
[timo]
Expand Down
9 changes: 7 additions & 2 deletions Products/PasswordResetTool/PasswordResetTool.py
Expand Up @@ -19,7 +19,9 @@
from App.special_dtml import DTMLFile
from AccessControl import ClassSecurityInfo
from AccessControl import ModuleSecurityInfo
from plone.registry.interfaces import IRegistry
from Products.CMFCore.permissions import ManagePortal
from Products.CMFPlone.interfaces import ISecuritySchema
try:
from Products.CMFPlone.RegistrationTool import get_member_by_login_name
except ImportError:
Expand All @@ -33,6 +35,7 @@
import time
import socket
from DateTime import DateTime
from zope.component import getUtility
from zope.interface import implements

module_security = ModuleSecurityInfo('Products.PasswordResetTool.PasswordResetTool')
Expand Down Expand Up @@ -346,8 +349,10 @@ def expirationDate(self):
def getValidUser(self, userid):
"""Returns the member with 'userid' if available and None otherwise."""
if get_member_by_login_name:
props = getToolByName(self, 'portal_properties').site_properties
if props.getProperty('use_email_as_login', False):
registry = getUtility(IRegistry)
settings = registry.forInterface(ISecuritySchema, prefix='plone')

if settings.use_email_as_login:
return get_member_by_login_name(
self, userid, raise_exceptions=False)
membertool = getToolByName(self, 'portal_membership')
Expand Down
Expand Up @@ -32,7 +32,7 @@
<div class="field"
tal:define="error errors/userid | nothing;
site_properties context/portal_properties/site_properties;
use_email_as_login site_properties/use_email_as_login|nothing;"
use_email_as_login python:context.portal_registry['plone.use_email_as_login'];"
tal:attributes="class python:test(error, 'field error', 'field')"
tal:condition="here/portal_password_reset/checkUser | nothing">

Expand Down

0 comments on commit 5a9bacc

Please sign in to comment.