Index: main/waeup.kofa/trunk/src/waeup/kofa/students/authentication.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/authentication.py	(revision 13366)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/authentication.py	(revision 13394)
@@ -113,7 +113,13 @@
         """Check whether the given `password` matches the one stored by
         students or the temporary password set by officers.
-
-        We additionally check if student account has been suspended.
-        """
+        We additionally check if student account has been suspended
+        or if the portal is blocked.
+        """
+        try:
+            blocker = grok.getSite()['configuration'].maintmode_enabled_by
+            if blocker:
+                return False
+        except TypeError:  # in unit tests
+            pass
         if not isinstance(password, basestring):
             return False
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 13366)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 13394)
@@ -1387,4 +1387,5 @@
         filewidget.add_file(filecontents, 'text/plain', 'students.csv')
         self.browser.getControl(name='SUBMIT').click()
+        self.browser.getLink("Switch maintenance mode").click()
         self.browser.getLink('Process data').click()
         button = lookup_submit_value(
@@ -1413,4 +1414,6 @@
         filewidget.add_file(filecontents, 'text/plain', 'studycourses.csv')
         self.browser.getControl(name='SUBMIT').click()
+        # Meanwhile maintenance mode is disabled again.
+        self.browser.getLink("Switch maintenance mode").click()
         self.browser.getLink('Process data').click()
         button = lookup_submit_value(
@@ -2376,4 +2379,30 @@
             '...You logged in...', self.browser.contents)
 
+    def test_maintenance_mode(self):
+        config = grok.getSite()['configuration']
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.student_id
+        self.browser.getControl(name="form.password").value = 'spwd'
+        self.browser.getControl("Login").click()
+        # Student logged in.
+        self.assertTrue('You logged in' in self.browser.contents)
+        self.assertTrue("Anna Tester" in self.browser.contents)
+        # If maintenance mode is enabled, student is immediately logged out.
+        config.maintmode_enabled_by = u'any_user'
+        self.assertRaises(
+            Unauthorized, self.browser.open, 'http://localhost/app/faculties')
+        self.browser.open('http://localhost/app/login')
+        self.assertTrue('The portal is in maintenance mode' in self.browser.contents)
+        # Student really can't login if maintenance mode is enabled.
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.student_id
+        self.browser.getControl(name="form.password").value = 'spwd'
+        self.browser.getControl("Login").click()
+        # A second warning is raised.
+        self.assertTrue(
+            'The portal is in maintenance mode. You can\'t login!'
+            in self.browser.contents)
+        return
+
     def test_student_clearance(self):
         # Student cant login if their password is not set
