Index: /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/browser/pages.py
===================================================================
--- /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/browser/pages.py	(revision 17610)
+++ /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/browser/pages.py	(revision 17611)
@@ -26,5 +26,5 @@
     SessionConfigurationManageFormPage,
     ConfigurationContainerManageFormPage,
-    SourcesOverview)
+    SourcesOverview, LoginPage)
 from waeup.kofa.browser.layout import KofaPage
 from kofacustom.nigeria.interfaces import (
@@ -33,4 +33,19 @@
     ICustomSessionConfigurationAdd)
 from kofacustom.nigeria.interfaces import MessageFactory as _
+
+class NigeriaLoginPage(LoginPage):
+    """A login page, available for all objects.
+    """
+
+    def update(self, SUBMIT=None, camefrom=None, login=None, password=None):
+
+        # Redirect to camefrom if user is still logged in. Don't show login page.
+        if camefrom and 'request_webservice' in camefrom and \
+            self.request.principal.id != 'zope.anybody':
+            self.redirect(self.application_url() + camefrom)
+            return
+
+        super(NigeriaLoginPage, self).update(SUBMIT, camefrom, login, password)
+
 
 class NigeriaSourcesOverview(SourcesOverview):
Index: /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py
===================================================================
--- /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py	(revision 17610)
+++ /main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/tests/test_browser.py	(revision 17611)
@@ -480,2 +480,30 @@
             '<h1 class="kofa-content-label">Edit clearance data</h1>'
             in self.browser.contents)
+
+    def test_student_redirect_camefrom(self):
+        payment1 = createObject(u'waeup.StudentOnlinePayment')
+        payment1.p_id = "p4153206270"
+        payment1.p_category = 'schoolfee'
+        payment1.p_item = u'My School Fee'
+        payment1.p_session = 2015
+        payment1.p_level = 100
+        payment1.p_current = True
+        payment1.amount_auth = 23456.9
+        payment1.approve()
+        self.student['payments'][payment1.p_id] = payment1
+        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()
+        self.assertMatches(
+            '...You logged in...', self.browser.contents)
+        camefrom = '/students/K1000000/studycourse'
+        self.browser.open(self.login_path + '?camefrom=%s' % camefrom)
+        # nothing happens
+        self.assertEqual(self.browser.url, self.login_path + '?camefrom=%s' % camefrom)
+        camefrom = '/students/K1000000/payments/%s/request_webservice' % payment1.p_id
+        # Kofa redirects to request_webservice and then returns to payment ticket index view
+        self.browser.open(self.login_path + '?camefrom=%s' % camefrom)
+        self.assertEqual(
+            self.browser.url,
+            'http://localhost/app/students/K1000000/payments/p4153206270/@@index')
