Index: main/waeup.ikoba/trunk/src/waeup/ikoba/browser/pages.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/browser/pages.py	(revision 11974)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/browser/pages.py	(revision 11975)
@@ -271,10 +271,10 @@
                         self.request.principal.id]
                     rel_link = '/customers/%s' % self.request.principal.id
-                    if customer.personal_data_expired:
-                        rel_link = '/customerss/%s/edit_personal' % (
-                            self.request.principal.id)
-                        self.flash(
-                          _('Your personal data record is outdated. Please update.'),
-                          type='warning')
+                    #if customer.personal_data_expired:
+                    #    rel_link = '/customers/%s/edit_personal' % (
+                    #        self.request.principal.id)
+                    #    self.flash(
+                    #      _('Your personal data record is outdated. Please update.'),
+                    #      type='warning')
                     self.redirect(self.application_url() + rel_link)
                     return
@@ -284,4 +284,33 @@
                 self.redirect(self.camefrom)
                 return
+            # Display appropriate flash message if credentials are correct
+            # but customer has been deactivated or a temporary password
+            # has been set.
+            login = self.request.form['form.login']
+            if len(login) == 8 and login in grok.getSite()['customers']:
+                customer = grok.getSite()['customers'][login]
+                password = self.request.form['form.password']
+                passwordmanager = getUtility(IPasswordManager, 'SSHA')
+                if customer.password is not None and \
+                    passwordmanager.checkPassword(customer.password, password):
+                    # The customer entered valid credentials.
+                    # First we check if a temporary password has been set.
+                    delta = timedelta(minutes=10)
+                    now = datetime.utcnow()
+                    temp_password_dict = getattr(customer, 'temp_password', None)
+                    if temp_password_dict is not None and \
+                        now < temp_password_dict.get('timestamp', now) + delta:
+                        self.flash(
+                            _('Your account has been temporarily deactivated.'),
+                            type='warning')
+                        return
+                    # Now we know that the customer is suspended.
+                    comment = self._comment(customer)
+                    if comment:
+                        self.flash(comment, type='warning')
+                    else:
+                        self.flash(_('Your account has been deactivated.'),
+                                   type='warning')
+                    return
             self.flash(_('You entered invalid credentials.'), type='danger')
             return
Index: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/mydatadropdowntabs.pt
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/mydatadropdowntabs.pt	(revision 11975)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/mydatadropdowntabs.pt	(revision 11975)
@@ -0,0 +1,13 @@
+<li  tal:attributes="class viewlet/active">
+  <a href="#" class="dropdown-toggle"
+     data-toggle="dropdown">
+     <span tal:replace="viewlet/tab_title">My Data</span>
+     <b class="caret"></b>
+  </a>
+  <ul class="dropdown-menu">
+    <li tal:repeat="target viewlet/targets">
+      <a tal:attributes="href target/url"
+         tal:content="target/title">LINKTITLE</a>
+    </li>
+  </ul>
+</li>
Index: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py	(revision 11974)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py	(revision 11975)
@@ -446,2 +446,54 @@
                         'K1000000 - account activated' in logcontent)
 
+
+    def test_login_as_customer(self):
+        # CustomerImpersonators can login as customer
+        # Create clearance officer
+        self.app['users'].addUser('mrofficer', 'mrofficersecret')
+        self.app['users']['mrofficer'].email = 'mrofficer@foo.ng'
+        self.app['users']['mrofficer'].title = 'Harry Actor'
+        prmglobal = IPrincipalRoleManager(self.app)
+        prmglobal.assignRoleToPrincipal('waeup.CustomerImpersonator', 'mrofficer')
+        prmglobal.assignRoleToPrincipal('waeup.CustomersManager', 'mrofficer')
+        # Login as customer impersonator
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = 'mrofficer'
+        self.browser.getControl(name="form.password").value = 'mrofficersecret'
+        self.browser.getControl("Login").click()
+        self.assertMatches('...You logged in...', self.browser.contents)
+        self.browser.open(self.customer_path)
+        self.browser.getLink("Login as").click()
+        self.browser.getControl("Set password now").click()
+        temp_password = self.browser.getControl(name='form.password').value
+        self.browser.getControl("Login now").click()
+        self.assertMatches(
+            '...You successfully logged in as...', self.browser.contents)
+        # We are logged in as customer and can see the 'My Data' tab
+        self.assertMatches(
+            '...<a href="#" class="dropdown-toggle" data-toggle="dropdown">...',
+            self.browser.contents)
+        self.assertMatches(
+            '...My Data...',
+            self.browser.contents)
+        self.browser.getLink("Logout").click()
+        # The customer can't login with the original password ...
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.customer_id
+        self.browser.getControl(name="form.password").value = 'spwd'
+        self.browser.getControl("Login").click()
+        self.assertMatches(
+            '...Your account has been temporarily deactivated...',
+            self.browser.contents)
+        # ... but with the temporary password
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.customer_id
+        self.browser.getControl(name="form.password").value = temp_password
+        self.browser.getControl("Login").click()
+        self.assertMatches('...You logged in...', self.browser.contents)
+        # Creation of temp_password is properly logged
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'customers.log')
+        logcontent = open(logfile).read()
+        self.assertTrue(
+            'mrofficer - customers.browser.LoginAsCustomerStep1 - K1000000 - '
+            'temp_password generated: %s' % temp_password in logcontent)
