added came_from to login.jinja2
This commit is contained in:
@@ -12,7 +12,7 @@ def main(global_config, **settings):
|
||||
# session factory
|
||||
my_session_factory = SignedCookieSessionFactory('mGcAJn2HmNH6Hc')
|
||||
|
||||
authentication_policy = AuthTktAuthenticationPolicy('wMWvAWMZnp6Lch',
|
||||
authentication_policy = AuthTktAuthenticationPolicy('J2wv322aL5DTn2',
|
||||
callback=groupfinder, hashalg='sha512', timeout=36000)
|
||||
authorization_policy = ACLAuthorizationPolicy()
|
||||
with Configurator(settings=settings,
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
<form action="{{ login_url }}" method="post">
|
||||
<h2>Se connecter</h2>
|
||||
<input type="hidden" name="came_from" value="{{ came_from }}" />
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" name="username" class="form-control" placeholder="Identifiant">
|
||||
</div>
|
||||
@@ -14,7 +16,7 @@
|
||||
<input type="password" name="password" class="form-control" placeholder="Mot de passe">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Se connecter" class="btn btn-primary">
|
||||
<input type="submit" name="form.submitted" value="Se connecter" class="btn btn-primary">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ def apropos(request):
|
||||
@view_config(route_name='login', renderer='cao_blogr:templates/login.jinja2')
|
||||
@forbidden_view_config(renderer='cao_blogr:templates/login.jinja2')
|
||||
def login(request):
|
||||
username = ''
|
||||
login_url = request.route_url('login')
|
||||
|
||||
referrer = request.url
|
||||
@@ -41,9 +40,11 @@ def login(request):
|
||||
referrer = '/' # never use the login form itself as came_from
|
||||
|
||||
came_from = request.params.get('came_from', referrer)
|
||||
username = request.POST.get('username')
|
||||
userpwd = request.POST.get('password')
|
||||
if username:
|
||||
username = ''
|
||||
userpwd = ''
|
||||
if 'form.submitted' in request.params:
|
||||
username = request.POST.get('username')
|
||||
userpwd = request.POST.get('password')
|
||||
user = UserService.by_name(request, username)
|
||||
if user and user.verify_password(userpwd):
|
||||
headers = remember(request, username)
|
||||
|
||||
Reference in New Issue
Block a user