Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Gambier
erp5
Commits
6ded2571
Commit
6ded2571
authored
Sep 30, 2022
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: str.encode('hex') does not work in Python 3.
parent
6488f71d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
5 deletions
+11
-5
bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.Person.py
...entTemplateItem/portal_components/document.erp5.Person.py
+4
-2
bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.py
...p5_credential/CredentialRequest_checkLoginAvailability.py
+4
-2
bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_newCredentialRequest.py
...al_skins/erp5_credential/ERP5Site_newCredentialRequest.py
+3
-1
No files found.
bt5/erp5_base/DocumentTemplateItem/portal_components/document.erp5.Person.py
View file @
6ded2571
...
...
@@ -27,11 +27,13 @@
#
##############################################################################
import
binascii
import
zope.interface
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
,
interfaces
from
Products.ERP5.Document.Node
import
Node
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
from
erp5.component.mixin.EncryptedPasswordMixin
import
EncryptedPasswordMixin
from
erp5.component.mixin.LoginAccountProviderMixin
import
LoginAccountProviderMixin
from
erp5.component.mixin.ERP5UserMixin
import
ERP5UserMixin
...
...
@@ -143,9 +145,9 @@ class Person(EncryptedPasswordMixin, Node, LoginAccountProviderMixin, ERP5UserMi
# Encode reference to hex to prevent uppercase/lowercase conflict in
# activity table (when calling countMessageWithTag)
if
user_id
:
tag
=
'set_userid_'
+
user_id
.
encode
(
'hex'
)
tag
=
'set_userid_'
+
bytes2str
(
binascii
.
hexlify
(
str2bytes
(
user_id
))
)
else
:
tag
=
'set_
login_'
+
login
.
encode
(
'hex'
)
tag
=
'set_
userid_'
+
bytes2str
(
binascii
.
hexlify
(
str2bytes
(
login
))
)
# Check that there no existing user
acl_users
=
getattr
(
self
,
'acl_users'
,
None
)
if
PluggableAuthService
is
not
None
and
isinstance
(
acl_users
,
...
...
bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/CredentialRequest_checkLoginAvailability.py
View file @
6ded2571
...
...
@@ -2,14 +2,16 @@
Parameters:
value -- field value (string)
REQUEST -- standard REQUEST variable"""
import
binascii
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
portal
=
context
.
getPortalObject
()
if
value
:
# Same tag is used as in ERP5 Login _setReference, in order to protect against
# concurrency between Credential Request and ERP5 Login object too
#
# XXX:
value.encode('hex')
may exceed 'tag' column length (255)...
if
context
.
getPortalObject
().
portal_activities
.
countMessageWithTag
(
'set_login_'
+
value
.
encode
(
'hex'
)):
# XXX:
hex encoded value
may exceed 'tag' column length (255)...
if
context
.
getPortalObject
().
portal_activities
.
countMessageWithTag
(
'set_login_'
+
bytes2str
(
binascii
.
hexlify
(
str2bytes2
(
value
))
)):
return
False
def
getRealContext
():
...
...
bt5/erp5_credential/SkinTemplateItem/portal_skins/erp5_credential/ERP5Site_newCredentialRequest.py
View file @
6ded2571
...
...
@@ -3,6 +3,8 @@ Paramameter list :
reference -- User login is mandatory (String)
default_email_text -- Email is mandatory (String)"""
# create the credential request
import
binascii
from
Products.ERP5Type.Utils
import
bytes2str
,
str2bytes
portal
=
context
.
getPortalObject
()
module
=
portal
.
getDefaultModule
(
portal_type
=
'Credential Request'
)
portal_preferences
=
portal
.
portal_preferences
...
...
@@ -39,7 +41,7 @@ credential_request = module.newContent(
credential_request
.
setCategoryList
(
category_list
)
# Same tag is used as in ERP5 Login._setReference, in order to protect against
# concurrency between Credential Request and Person object too
tag
=
'set_login_%s'
%
reference
.
encode
(
'hex'
)
tag
=
'set_login_%s'
%
bytes2str
(
binascii
.
hexlify
(
str2bytes2
(
reference
))
)
credential_request
.
reindexObject
(
activate_kw
=
{
'tag'
:
tag
})
#We attach the current user to the credential request if not anonymous
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment