Skip to content

Commit

Permalink
feat: redirect to cas login in case of a require_login
Browse files Browse the repository at this point in the history
  • Loading branch information
Adria DEV committed Aug 12, 2013
1 parent f459b42 commit 709288b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
17 changes: 17 additions & 0 deletions src/collective/castle/configure.zcml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:cmf="http://namespaces.zope.org/cmf"
xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:five="http://namespaces.zope.org/five"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
Expand Down Expand Up @@ -62,6 +63,16 @@
profile="collective.castle:default"
/>

<genericsetup:upgradeStep
title="Add skins"
description=""
source="*"
destination="6"
handler="collective.castle.setuphandlers.upgrade_skins"
sortkey="1"
profile="collective.castle:default"
/>



<browser:page
Expand Down Expand Up @@ -110,4 +121,10 @@
preserveOriginal="true"
/>

<cmf:registerDirectory
name="skins"
directory="skins"
recursive="True"
/>

</configure>
2 changes: 1 addition & 1 deletion src/collective/castle/profiles/default/metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<description>
Installs Plone UI for CAS authentication support through Products.CAS4PAS.
</description>
<version>5</version>
<version>6</version>
<dependencies>
<dependency>profile-plone.app.registry:default</dependency>
</dependencies>
Expand Down
11 changes: 11 additions & 0 deletions src/collective/castle/profiles/default/skins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<object name="portal_skins" default_skin="">

<object name="collective_castle_login" meta_type="Filesystem Directory View"
directory="collective.castle:skins/collective_castle_login"/>

<skin-path name="*">
<layer name="collective_castle_login" insert-after="custom"/>
</skin-path>

</object>
8 changes: 3 additions & 5 deletions src/collective/castle/setuphandlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def upgrade_controlpanel(context):
def upgrade_actions(context):
run_import_step(context, 'actions')

def upgrade_skins(context):
run_import_step(context, 'skins')

def upgrade_registry(context):
run_import_step(context, 'plone.app.registry')

Expand All @@ -42,8 +45,3 @@ def upgrade_to_plone_app_registry(context):
#Convert old strings to unicode
old_value = unicode(old_value)
setattr(settings, key, old_value)





Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Script (Python) "require_login"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Login

login = 'login'

portal = context.portal_url.getPortalObject()
# if cookie crumbler did a traverse instead of a redirect,
# this would be the way to get the value of came_from
#url = portal.getCurrentUrl()
#context.REQUEST.set('came_from', url)

if context.portal_membership.isAnonymousUser():
url = context.restrictedTraverse('@@castle_login_url')()
context.REQUEST.response.redirect(url)
return
else:
return portal.restrictedTraverse('insufficient_privileges')()

0 comments on commit 709288b

Please sign in to comment.