equal
deleted
inserted
replaced
1 """ Provide login views that reproduce a classical CubicWeb behavior""" |
1 """ Provide login views that reproduce a classical CubicWeb behavior""" |
2 from pyramid import security |
2 from pyramid import security |
3 from pyramid.httpexceptions import HTTPSeeOther |
3 from pyramid.httpexceptions import HTTPSeeOther |
4 from pyramid.view import view_config |
4 from pyramid.view import view_config |
|
5 from pyramid.settings import asbool |
5 |
6 |
6 import cubicweb |
7 import cubicweb |
7 |
8 |
8 from pyramid_cubicweb.core import render_view |
9 from pyramid_cubicweb.core import render_view |
9 |
10 |
50 "Authentication failed. Please check your credentials.")) |
51 "Authentication failed. Please check your credentials.")) |
51 request.cw_request.post = dict(request.params) |
52 request.cw_request.post = dict(request.params) |
52 del request.cw_request.post['__password'] |
53 del request.cw_request.post['__password'] |
53 return login_form(request) |
54 return login_form(request) |
54 |
55 |
55 max_age = None |
56 headers = security.remember( |
56 if request.params.get('__setauthcookie') == '1': |
57 request, user_eid, |
57 max_age = 604800 |
58 persistent=asbool(request.params.get('__setauthcookie', False))) |
58 headers = security.remember(request, user_eid, max_age=max_age) |
|
59 |
59 |
60 new_path = request.params.get('postlogin_path', '/') |
60 new_path = request.params.get('postlogin_path', '/') |
61 |
61 |
62 if new_path == 'login': |
62 if new_path == 'login': |
63 new_path = '/' |
63 new_path = '/' |