Commit 6433544c authored by Rafael Monnerat's avatar Rafael Monnerat

Drop Configurator Key implementation

Configurator Key is a legacy.
parent 9a74e608
...@@ -142,68 +142,31 @@ class ConfiguratorTool(BaseTool): ...@@ -142,68 +142,31 @@ class ConfiguratorTool(BaseTool):
###################################################### ######################################################
def login(self, REQUEST): def login(self, REQUEST):
""" Login client and show next form. """ """ Login client and show next form. """
password = REQUEST.get('field_my_ac_key', '')
bc = REQUEST.get('field_your_business_configuration') bc = REQUEST.get('field_your_business_configuration')
if self._isCorrectConfigurationKey(password, bc): user_preferred_language = REQUEST.get(
# set user preferred configuration language 'field_my_user_preferred_language', None)
user_preferred_language = REQUEST.get( if user_preferred_language:
'field_my_user_preferred_language', None) # Set language value to request so that next page after login
if user_preferred_language: # can get the value. Because cookie value is available from
# Set language value to request so that next page after login # next request.
# can get the value. Because cookie value is available from REQUEST.set(LANGUAGE_COOKIE_NAME, user_preferred_language)
# next request. REQUEST.RESPONSE.setCookie(LANGUAGE_COOKIE_NAME,
REQUEST.set(LANGUAGE_COOKIE_NAME, user_preferred_language)
REQUEST.RESPONSE.setCookie(LANGUAGE_COOKIE_NAME,
user_preferred_language, user_preferred_language,
path='/', path='/',
expires=(DateTime() + 30).rfc822()) expires=(DateTime() + 30).rfc822())
# set encoded __ac_key cookie at client's browser
__ac_key = quote(encodestring(password))
expires = (DateTime() + 1).toZone('GMT').rfc822()
REQUEST.RESPONSE.setCookie('__ac_key',
__ac_key,
expires=expires)
REQUEST.set('__ac_key', __ac_key)
REQUEST.RESPONSE.setCookie(BUSINESS_CONFIGURATION_COOKIE_NAME,
bc,
expires=expires)
REQUEST.set(BUSINESS_CONFIGURATION_COOKIE_NAME, bc)
return self.next(REQUEST=REQUEST)
else:
REQUEST.set('portal_status_message',
self.Base_translateString('Incorrect Configuration Key'))
return self.view()
def _isCorrectConfigurationKey(self, password=None, expires = (DateTime() + 1).toZone('GMT').rfc822()
business_configuration=None): REQUEST.RESPONSE.setCookie(BUSINESS_CONFIGURATION_COOKIE_NAME,
""" Is configuration key correct """ bc,
if password is None: expires=expires)
password = self.REQUEST.get('__ac_key', None) REQUEST.set(BUSINESS_CONFIGURATION_COOKIE_NAME, bc)
else: return self.next(REQUEST=REQUEST)
password = quote(encodestring(password))
# Not still not finished yet.
if business_configuration is None:
business_configuration = self.REQUEST.get(
BUSINESS_CONFIGURATION_COOKIE_NAME, None)
if None not in [password, business_configuration]:
def is_key_valid(password, business_configuration):
bc = self.getPortalObject().unrestrictedTraverse(business_configuration)
return quote(encodestring(bc.getReference(''))) == password
return CachingMethod(is_key_valid,
"ConfiguratorTool_is_key_valid",
cache_factory='erp5_content_long')(
password, business_configuration)
return False
#security.declareProtected(Permissions.ModifyPortalContent, 'next') #security.declareProtected(Permissions.ModifyPortalContent, 'next')
def next(self, REQUEST): def next(self, REQUEST):
""" Validate settings and return a new form to the user. """ """ Validate settings and return a new form to the user. """
# check if user is allowed to access service # check if user is allowed to access service
portal = self.getPortalObject() portal = self.getPortalObject()
if not self._isCorrectConfigurationKey():
REQUEST.set('portal_status_message',
self.Base_translateString('Incorrect Configuration Key'))
return self.view()
kw = self.REQUEST.form.copy() kw = self.REQUEST.form.copy()
business_configuration = REQUEST.get(BUSINESS_CONFIGURATION_COOKIE_NAME) business_configuration = REQUEST.get(BUSINESS_CONFIGURATION_COOKIE_NAME)
bc = portal.restrictedTraverse(business_configuration) bc = portal.restrictedTraverse(business_configuration)
...@@ -382,10 +345,6 @@ class ConfiguratorTool(BaseTool): ...@@ -382,10 +345,6 @@ class ConfiguratorTool(BaseTool):
""" Display the previous form. """ """ Display the previous form. """
# check if user is allowed to access service # check if user is allowed to access service
portal = self.getPortalObject() portal = self.getPortalObject()
if not self._isCorrectConfigurationKey():
REQUEST.set('portal_status_message',
self.Base_translateString('Incorrect Configuration Key'))
return self.view()
kw = self.REQUEST.form.copy() kw = self.REQUEST.form.copy()
business_configuration = REQUEST.get(BUSINESS_CONFIGURATION_COOKIE_NAME) business_configuration = REQUEST.get(BUSINESS_CONFIGURATION_COOKIE_NAME)
bc = portal.restrictedTraverse(business_configuration) bc = portal.restrictedTraverse(business_configuration)
...@@ -461,8 +420,6 @@ class ConfiguratorTool(BaseTool): ...@@ -461,8 +420,6 @@ class ConfiguratorTool(BaseTool):
installation_status['activity_list'] = [] installation_status['activity_list'] = []
active_process = self.portal_activities.newActiveProcess() active_process = self.portal_activities.newActiveProcess()
REQUEST.set('active_process_id', active_process.getId()) REQUEST.set('active_process_id', active_process.getId())
request_restore_dict = {'__ac_key': REQUEST.get('__ac_key',
None), }
self.activate(active_process=active_process, tag='initialERP5Setup' self.activate(active_process=active_process, tag='initialERP5Setup'
).initialERP5Setup(business_configuration.getRelativeUrl(), request_restore_dict) ).initialERP5Setup(business_configuration.getRelativeUrl(), request_restore_dict)
return self.ConfiguratorTool_viewInstallationStatus(REQUEST) return self.ConfiguratorTool_viewInstallationStatus(REQUEST)
......
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