Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
d14437cc4556
Commit
fc0c39b4
authored
Feb 26, 2021
by
François Ferry
Browse files
feat: create anonymous user at runtime if it doesn't exist already.
related:
#88
parent
f386f98916f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
cubicweb/pyramid/core.py
View file @
d14437cc
...
...
@@ -386,8 +386,19 @@ def includeme(config):
with
repo
.
internal_cnx
()
as
cnx
:
login
=
config
.
registry
[
'cubicweb.config'
].
anonymous_user
()[
0
]
if
login
is
not
None
:
config
.
registry
[
'cubicweb.anonymous_eid'
]
=
cnx
.
find
(
'CWUser'
,
login
=
login
).
one
().
eid
try
:
config
.
registry
[
'cubicweb.anonymous_eid'
]
=
cnx
.
find
(
'CWUser'
,
login
=
login
).
one
().
eid
except
cubicweb
.
NoResultError
:
# Anonymous access is enabled, but anonymous user doesn't exist
# which happens when we authorized anonymous access on a previously
# private instance.
from
cubicweb.server
import
create_user
anonlogin
,
anonpwd
=
config
.
registry
[
'cubicweb.config'
].
anonymous_user
()
create_user
(
cnx
,
anonlogin
,
anonpwd
,
'guests'
)
cnx
.
commit
()
config
.
registry
[
'cubicweb.anonymous_eid'
]
=
cnx
.
find
(
'CWUser'
,
login
=
login
).
one
().
eid
config
.
add_request_method
(
_cw_session
,
name
=
'cw_session'
,
property
=
True
,
reify
=
True
)
...
...
Write
Preview
Supports
Markdown
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