Index: WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py	(revision 1004)
+++ WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py	(revision 1006)
@@ -48,25 +48,44 @@
 member = mtool.getAuthenticatedMember()
 
-if not is_anon:
-    if "Student" in member.getRoles():
-        to_waeup_student_home = True
-        students = context.portal_url.getPortalObject().campus.students
-        student = getattr(students,str(member))
-        student_app = getattr(student,'application')
-        student_pume = getattr(student,'pume',None)
-        s_review_state = wftool.getInfoFor(student,'review_state',None)
-        a_review_state = wftool.getInfoFor(student_app,'review_state',None)
-        logger.info('%s review_state %s' % (member,s_review_state))
-        app_doc = student_app.getContent()
-        #from Products.zdb import set_trace
-        #set_trace()
-        if s_review_state in ("student_created","admitted") and\
-        a_review_state == 'created' :
-            wftool.doActionFor(student_app,'open')
-            if student_pume is not None:
-              wftool.doActionFor(student_pume,'close')
-            da = {}
-            pin = request.get('pin')
-            if not pin:
+if redirect_url.endswith('/logged_out'):
+    redirect_to_portal = True    
+else:
+    if not is_anon:
+        if "Student" in member.getRoles():
+            to_waeup_student_home = True
+            students = context.portal_url.getPortalObject().campus.students
+            student = getattr(students,str(member))
+            student_app = getattr(student,'application')
+            student_pume = getattr(student,'pume',None)
+            s_review_state = wftool.getInfoFor(student,'review_state',None)
+            a_review_state = wftool.getInfoFor(student_app,'review_state',None)
+            logger.info('%s review_state %s' % (member,s_review_state))
+            app_doc = student_app.getContent()
+            #from Products.zdb import set_trace
+            #set_trace()
+            if s_review_state in ("student_created","admitted") and\
+            a_review_state == 'created' :
+                wftool.doActionFor(student_app,'open')
+                if student_pume is not None:
+                  wftool.doActionFor(student_pume,'close')
+                da = {}
+                pin = request.get('pin')
+                if not pin:
+                    jamb_reg_no = app_doc.jamb_reg_no
+                    for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
+                        res = context.portal_pins(student=reg_no)
+                        if len(res) > 0:
+                            break
+                    if len(res) > 0:
+                        p = res[0].pin
+                        if len(p) > 10:
+                            pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
+                        else:
+                            pin = p
+                da['app_ac_pin'] = pin
+                da['app_ac_date'] = current
+                app_doc.edit(mapping = da)
+            elif s_review_state in ("admitted") and a_review_state == 'opened' and\
+            not app_doc.app_ac_pin:
                 jamb_reg_no = app_doc.jamb_reg_no
                 for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
@@ -80,27 +99,11 @@
                     else:
                         pin = p
-            da['app_ac_pin'] = pin
-            da['app_ac_date'] = current
-            app_doc.edit(mapping = da)
-        elif s_review_state in ("admitted") and a_review_state == 'opened' and\
-        not app_doc.app_ac_pin:
-            jamb_reg_no = app_doc.jamb_reg_no
-            for reg_no in (jamb_reg_no,jamb_reg_no.lower(),jamb_reg_no.upper()):
-                res = context.portal_pins(student=reg_no)
-                if len(res) > 0:
-                    break
-            if len(res) > 0:
-                p = res[0].pin
-                if len(p) > 10:
-                    pin = "%s-%s-%s" % (p[:3],p[3:4],p[4:])
-                else:
-                    pin = p
-                da = {}
-                da['app_ac_pin'] = pin
-                app_doc.edit(mapping = da)
-    elif "Manager" in member.getRoles():
-        pass
-    else:
-        to_member_home, to_workspaces = checkRedirect(portal, mtool)
+                    da = {}
+                    da['app_ac_pin'] = pin
+                    app_doc.edit(mapping = da)
+        elif "Manager" in member.getRoles():
+            pass
+        else:
+            to_member_home, to_workspaces = checkRedirect(portal, mtool)
 if (not to_member_home) and (not to_workspaces):
     redirect_to_portal = True
Index: WAeUP_SRP/trunk/skins/waeup_custom/standard_error_message.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_custom/standard_error_message.pt	(revision 1004)
+++ WAeUP_SRP/trunk/skins/waeup_custom/standard_error_message.pt	(revision 1006)
@@ -8,4 +8,9 @@
                         p_props here/portal_properties;
                        ">
+<tal:Anauthorized condition="python:error_type == 'Unauthorized'">
+    <metal:block use-macro="here/error_not_found/macros/not_found" />
+</tal:Anauthorized>
+
+<tal:Anauthorized condition="python:error_type != 'Unauthorized'">
 <metal:body use-macro="here/main_template/macros/master">
 
@@ -53,3 +58,4 @@
 </metal:main>
 </metal:body>
+</tal:Anauthorized>
 </metal:html>
