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
Labels
Merge Requests
139
Merge Requests
139
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
ce2eaca9
Commit
ce2eaca9
authored
Mar 22, 2023
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Security: Allow user to login with a user created on the same transaction (improve a bit)
squash me
parent
f0a9bd71
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
26 deletions
+37
-26
product/ERP5Security/ERP5LoginUserManager.py
product/ERP5Security/ERP5LoginUserManager.py
+37
-26
No files found.
product/ERP5Security/ERP5LoginUserManager.py
View file @
ce2eaca9
...
...
@@ -111,21 +111,9 @@ class ERP5LoginUserManager(BasePlugin):
if
login_value
is
None
:
return
user_value
=
login_value
.
getParentValue
()
if
not
user_value
.
hasUserId
():
return
if
user_value
.
getValidationState
()
==
'deleted'
:
return
if
user_value
.
getPortalType
()
in
(
'Person'
,
):
now
=
DateTime
()
for
assignment
in
user_value
.
contentValues
(
portal_type
=
"Assignment"
):
if
assignment
.
getValidationState
()
==
"open"
and
(
not
assignment
.
hasStartDate
()
or
assignment
.
getStartDate
()
<=
now
)
and
(
not
assignment
.
hasStopDate
()
or
assignment
.
getStopDate
()
>=
now
):
break
else
:
if
not
self
.
_isUserValueValid
(
user_value
):
return
is_authentication_policy_enabled
=
self
.
getPortalObject
().
portal_preferences
.
isAuthenticationPolicyEnabled
()
if
check_password
:
password
=
credentials
.
get
(
'password'
)
...
...
@@ -148,6 +136,27 @@ class ERP5LoginUserManager(BasePlugin):
return
return
(
user_value
.
getUserId
(),
login_value
.
getReference
())
def
_isUserValueValid
(
self
,
user_value
):
if
not
user_value
.
hasUserId
():
return
if
user_value
.
getValidationState
()
==
'deleted'
:
return
if
user_value
.
getPortalType
()
in
(
'Person'
,
):
now
=
DateTime
()
for
assignment
in
user_value
.
contentValues
(
portal_type
=
"Assignment"
):
if
assignment
.
getValidationState
()
==
"open"
and
(
not
assignment
.
hasStartDate
()
or
assignment
.
getStartDate
()
<=
now
)
and
(
not
assignment
.
hasStopDate
()
or
assignment
.
getStopDate
()
>=
now
):
return
True
else
:
return
return
True
def
_getLoginValueFromLogin
(
self
,
login
,
login_portal_type
=
None
):
try
:
user_list
=
self
.
enumerateUsers
(
...
...
@@ -286,26 +295,28 @@ class ERP5LoginUserManager(BasePlugin):
]
tv
=
getTransactionalVariable
()
person
=
tv
.
get
(
"transactional_user"
,
None
)
if
person
is
not
None
:
erp5_login
=
person
.
objectValues
(
"ERP5 Login"
)[
0
]
if
(
login
is
not
None
and
erp5_login
.
getReference
()
==
None
)
or
\
(
id
is
not
None
and
person
.
getUserId
()
==
id
[
0
]):
user_value
=
tv
.
get
(
"transactional_user"
,
None
)
if
user_value
is
not
None
and
self
.
_isUserValueValid
(
user_value
):
login_value
=
[
l
for
l
in
user_value
.
objectValues
(
login_portal_type
)
if
l
.
getValidationState
()
==
'validated'
][
0
]
if
(
login_value
is
not
None
and
login_value
.
getReference
()
is
not
None
)
and
\
(
id
is
not
None
and
user_value
.
getUserId
()
==
id
[
0
]):
result
.
append
({
'id'
:
person
.
getUserId
(),
'id'
:
user_value
.
getUserId
(),
# Note: PAS forbids us from returning more than one entry per given id,
# so take any available login.
'login'
:
erp5_login
.
getReference
(),
'login'
:
login_value
.
getReference
(),
'pluginid'
:
plugin_id
,
# Extra properties, specific to ERP5
'path'
:
person
.
getPath
(),
'uid'
:
person
.
getUid
(),
'path'
:
user_value
.
getPath
(),
'uid'
:
user_value
.
getUid
(),
'login_list'
:
[
{
'reference'
:
erp5_login
.
getReference
(),
'path'
:
erp5_login
.
getRelativeUrl
(),
'uid'
:
erp5_login
.
getPath
(),
'reference'
:
login_value
.
getReference
(),
'path'
:
login_value
.
getRelativeUrl
(),
'uid'
:
login_value
.
getPath
(),
}
],
})
...
...
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