Commit 46b3ab24 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_advanced_ecommerce: add facebook login

parent 37a97743
portal = context.getPortalObject()
person_list = [x for x in portal.acl_users.searchUsers(login=user_reference, exact_match=True) if 'path' in x]
if person_list:
return
person = portal.person_module.newContent(
portal_type='Person',
title = user_dict['name']
)
user_id = person.Person_getUserId()
# Create default career
# Create assignment
assignment = person.newContent(portal_type='Assignment',
role='client',) # Required for security based on role
login = person.newContent(portal_type='Facebook Login', reference=user_reference)
login.validate()
assignment.open()
person.validate()
person.manage_setLocalRoles(user_id, ['Auditor'])
person.WebSite_immediateReindex()
login.WebSite_immediateReindex()
# Set owner local role for cart if needed
shopping_cart = context.SaleOrder_getShoppingCart()
if shopping_cart is not None:
shopping_cart.manage_setLocalRoles(user_id, ['Owner'])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>user_reference, user_dict</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_createFacebookUserToOAuth</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,7 +10,9 @@ if result_type != 'edit':
# Update data
kw, _ = result
context.edit(**kw)
context.WebSite_executeMethodAsSuperUser('edit', **kw)
#context.edit(**kw)
login_come_from_url = context.REQUEST.get("field_your_login_come_from_url")
edit_portal_status_message = context.REQUEST.get("field_your_edit_portal_status_message",
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSite_viewLoginForm</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<tal:block tal:define="login_come_from_url python: request.get('field_your_login_come_from_url', None) or request.get('came_from', None) or '..';
is_shopping_cart python: request.get('field_your_is_shopping_cart') and 1 or 0;
is_loyalty_section python: login_come_from_url.endswith('loyalty') and 1 or 0;">
<p tal:condition="python: not is_shopping_cart and not is_loyalty_section" i18n:translate="" i18n:domain="ui">
Use your Facebook accounts to signup
</p>
<p tal:condition="is_shopping_cart" i18n:translate="" i18n:domain="ui">
Before we can proceed to payment, please login with your Facebook account.
</p>
<p tal:condition="is_loyalty_section" i18n:translate="" i18n:domain="ui">
Before access loyalty area, please login with your Facebook account.
</p>
<p>
<a class="zocial facebook" href="ERP5Site_redirectToFacebookLoginPage" i18n:translate="" i18n:domain="ui">Signup with Facebook</a>
</p>
<p>
<a class="login_old_style" tal:attributes="href string:./login_form?is_traditional_login:int=1&is_shopping_cart:int=${is_shopping_cart}&is_loyalty_section:int=${is_loyalty_section}&came_from=${login_come_from_url}&"
i18n:translate="" i18n:domain="ui">
or login using a traditional account...
</a>
</p>
</tal:block>
\ No newline at end of file
......@@ -79,6 +79,7 @@
<value>
<list>
<string>traditional_login_html</string>
<string>login_html</string>
</list>
</value>
</item>
......
......@@ -148,7 +148,9 @@
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>external_validator</string> </key>
......@@ -304,4 +306,17 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: request.get("is_traditional_login")</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -5,3 +5,4 @@ erp5_web_multiflex5_theme
erp5_dms
erp5_jquery_plugin_jqzoom
erp5_jquery_plugin_lightbox
erp5_oauth_facebook_login
\ No newline at end of file
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