Index: main/waeup.ikoba/trunk/src/waeup/ikoba/browser/pages.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/browser/pages.py	(revision 11971)
+++ 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
