Commit 09293477 authored by Łukasz Nowak's avatar Łukasz Nowak

Allow to edit plugin.

parent cdbbb49b
...@@ -35,7 +35,7 @@ from Products.PluggableAuthService.utils import classImplements ...@@ -35,7 +35,7 @@ from Products.PluggableAuthService.utils import classImplements
from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin from Products.PluggableAuthService.plugins.BasePlugin import BasePlugin
from Products.ERP5Security.ERP5UserManager import SUPER_USER from Products.ERP5Security.ERP5UserManager import SUPER_USER
from Products.PluggableAuthService.PluggableAuthService import DumbHTTPExtractor from Products.PluggableAuthService.PluggableAuthService import DumbHTTPExtractor
from Products.PluggableAuthService.permissions import ManageUsers
from AccessControl.SecurityManagement import getSecurityManager,\ from AccessControl.SecurityManagement import getSecurityManager,\
setSecurityManager, newSecurityManager setSecurityManager, newSecurityManager
from DateTime import DateTime from DateTime import DateTime
...@@ -67,6 +67,22 @@ class ERP5BearerExtractionPlugin(BasePlugin): ...@@ -67,6 +67,22 @@ class ERP5BearerExtractionPlugin(BasePlugin):
meta_type = "ERP5 Bearer Extraction Plugin" meta_type = "ERP5 Bearer Extraction Plugin"
security = ClassSecurityInfo() security = ClassSecurityInfo()
token_portal_type = ''
manage_options = (({'label': 'Edit',
'action': 'manage_editERP5BearerExtractionPluginForm',},
)
+ BasePlugin.manage_options[:]
)
_properties = (({'id':'token_portal_type',
'type':'string',
'mode':'w',
'label':'Portal Type with tokens'
},
)
+ BasePlugin._properties[:]
)
def __init__(self, id, token_portal_type, title=None): def __init__(self, id, token_portal_type, title=None):
#Register value #Register value
...@@ -85,7 +101,7 @@ class ERP5BearerExtractionPlugin(BasePlugin): ...@@ -85,7 +101,7 @@ class ERP5BearerExtractionPlugin(BasePlugin):
if request._auth is not None: if request._auth is not None:
# 1st - try to fetch from Authorization header # 1st - try to fetch from Authorization header
if 'Bearer' in request._auth: if 'Bearer' in request._auth:
l = authorisation.split() l = request._auth.split()
if len(l) == 2: if len(l) == 2:
token = l[1] token = l[1]
...@@ -132,6 +148,33 @@ class ERP5BearerExtractionPlugin(BasePlugin): ...@@ -132,6 +148,33 @@ class ERP5BearerExtractionPlugin(BasePlugin):
# fallback to default way # fallback to default way
return DumbHTTPExtractor().extractCredentials(request) return DumbHTTPExtractor().extractCredentials(request)
manage_editERP5BearerExtractionPluginForm = PageTemplateFile(
'www/ERP5Security_editERP5BearerExtractionPlugin',
globals(),
__name__='manage_editERP5BearerExtractionPluginForm')
security.declareProtected(ManageUsers, 'manage_editERP5BearerExtractionPlugin')
def manage_editERP5BearerExtractionPlugin(self, token_portal_type, RESPONSE=None):
"""Edit the object"""
error_message = ''
if token_portal_type == '' or token_portal_type is None:
error_message += 'Token Portal Type is missing '
else:
self.token_portal_type = token_portal_type
#Redirect
if RESPONSE is not None:
if error_message != '':
self.REQUEST.form['manage_tabs_message'] = error_message
return self.manage_editERP5BearerExtractionPluginForm(RESPONSE)
else:
message = "Updated"
RESPONSE.redirect('%s/manage_editERP5BearerExtractionPluginForm'
'?manage_tabs_message=%s'
% (self.absolute_url(), message)
)
#List implementation of class #List implementation of class
classImplements( ERP5BearerExtractionPlugin, classImplements( ERP5BearerExtractionPlugin,
plugins.ILoginPasswordHostExtractionPlugin plugins.ILoginPasswordHostExtractionPlugin
......
<h1 tal:replace="structure context/manage_page_header">PAGE HEADER</h1>
<h2 tal:replace="structure here/manage_tabs"> TABS </h2>
<h2 tal:define="form_title string:Edit ERP5 Bearer Extraction Plugin"
tal:replace="structure context/manage_form_title">FORM TITLE</h2>
<p class="form-help">Please configure portal type containing tokens</p>
<form action="manage_editERP5BearerExtractionPlugin" method="POST">
<table tal:define="token_portal_type request/token_portal_type|context/token_portal_type|string:;">
<tr>
<td>Portal Type with tokens</td>
<td>
<input type="text" name="token_portal_type" value=""
tal:attributes="value token_portal_type;" />
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="save"/>
</td>
</tr>
</table>
</form>
<h1 tal:replace="structure context/manage_page_footer">PAGE FOOTER</h1>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment