author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Fri, 04 Sep 2009 16:13:04 +0200 | |
branch | stable |
changeset 3105 | b788903e77d5 |
parent 1977 | 606923dff11b |
child 4212 | ab6573088b4a |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
3 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
4 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
""" |
0 | 8 |
from cubicweb.web import Redirect |
9 |
from cubicweb.web.application import CubicWebPublisher |
|
10 |
||
11 |
# proof of concept : monkey patch publish method so that if we are in an |
|
12 |
# anonymous session and __fblogin is found is req.form, the user with the |
|
13 |
# given login is created if necessary and then a session is opened for that |
|
14 |
# user |
|
15 |
# NOTE: this require "cookie" authentication mode |
|
16 |
def auto_login_publish(self, path, req): |
|
17 |
if (req.cnx is None or req.cnx.anonymous_connection) and req.form.get('__fblogin'): |
|
18 |
login = password = req.form.pop('__fblogin') |
|
19 |
self.repo.register_user(login, password) |
|
20 |
req.form['__login'] = login |
|
21 |
req.form['__password'] = password |
|
22 |
if req.cnx: |
|
23 |
req.cnx.close() |
|
24 |
req.cnx = None |
|
25 |
try: |
|
26 |
self.session_handler.set_session(req) |
|
27 |
except Redirect: |
|
28 |
pass |
|
29 |
assert req.user.login == login |
|
30 |
return orig_publish(self, path, req) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
31 |
|
0 | 32 |
orig_publish = CubicWebPublisher.main_publish |
33 |
CubicWebPublisher.main_publish = auto_login_publish |