Ignore:
Timestamp:
30 Jan 2015, 11:09:08 (10 years ago)
Author:
Henrik Bettermann
Message:

Customers can use their email address for authentication.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/customers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/authentication.py

    r11997 r12523  
    1 ## $Id: authentication.py 10055 2013-04-04 15:12:43Z uli $
     1## $Id$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    2222import time
    2323from zope.component import getUtility
     24from zope.catalog.interfaces import ICatalog
    2425from zope.password.interfaces import IPasswordManager
    2526from zope.pluggableauth.interfaces import (
     
    187188        customer = customerscontainer.get(login, None)
    188189        if customer is None:
    189             return None
     190            cat = getUtility(ICatalog, name='customers_catalog')
     191            results = list(
     192                cat.searchResults(email=(login, login)))
     193            if len(results) != 1:
     194                return None
     195            customer = results[0]
    190196        return IUserAccount(customer)
    191197
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12521 r12523  
    227227    email = TextLineChoice(
    228228        title = _(u'Email'),
    229         required = False,
     229        required = True,
    230230        constraint=validate_email,
    231231        source = contextual_email_source,
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12521 r12523  
    550550    # Tests for Customer class views and pages
    551551
     552    def test_customer_login_with_email(self):
     553        self.assertEqual(self.customer.state, 'created')
     554        self.browser.open(self.login_path)
     555        self.browser.getControl(name="form.login").value = self.customer.email
     556        self.browser.getControl(name="form.password").value = 'cpwd'
     557        self.browser.getControl("Login").click()
     558        self.assertEqual(self.browser.url, self.customer_path)
     559        self.assertTrue('You logged in' in self.browser.contents)
     560        # Status has changed
     561        self.assertEqual(self.customer.state, 'started')
     562        return
     563
    552564    def test_customer_change_password(self):
    553565        # Customers can change the password
Note: See TracChangeset for help on using the changeset viewer.