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
alecs_myu
erp5
Commits
1f079e64
Commit
1f079e64
authored
Oct 21, 2016
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PasswordTool: use python's uuid module to generate random unique id
parent
fc297215
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
19 deletions
+2
-19
product/ERP5/Tool/PasswordTool.py
product/ERP5/Tool/PasswordTool.py
+2
-19
No files found.
product/ERP5/Tool/PasswordTool.py
View file @
1f079e64
...
...
@@ -28,6 +28,7 @@
##############################################################################
import
socket
import
uuid
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type.Globals
import
InitializeClass
,
DTMLFile
,
get_request
...
...
@@ -80,7 +81,7 @@ class PasswordTool(BaseTool):
expiration_date
=
DateTime
()
+
self
.
_expiration_day
# generate a random string
key
=
self
.
_generateUUID
()
key
=
uuid
.
uuid4
().
hex
if
isinstance
(
self
.
_password_request_dict
,
PersistentMapping
):
LOG
(
'ERP5.PasswordTool'
,
INFO
,
'Migrating password_request_dict to'
' OOBTree'
)
...
...
@@ -217,24 +218,6 @@ class PasswordTool(BaseTool):
return
redirect
(
REQUEST
,
site_url
,
translateString
(
"An email has been sent to you."
))
def
_generateUUID
(
self
,
args
=
""
):
"""
Generate a unique id that will be used as url for password
"""
# this code is based on
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761
# by Carl Free Jr
# as uuid module is only available in pyhton 2.5
t
=
long
(
time
.
time
()
*
1000
)
r
=
long
(
random
.
random
()
*
100000000000000000L
)
try
:
a
=
socket
.
gethostbyname
(
socket
.
gethostname
()
)
except
:
# if we can't get a network address, just imagine one
a
=
random
.
random
()
*
100000000000000000L
data
=
' '
.
join
((
str
(
t
),
str
(
r
),
str
(
a
),
str
(
args
)))
return
md5
(
data
).
hexdigest
()
security
.
declareProtected
(
Permissions
.
ModifyPortalContent
,
'removeExpiredRequests'
)
def
removeExpiredRequests
(
self
):
"""
...
...
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