Skip to content
Snippets Groups Projects
Commit 342b88ea authored by Alexandre Ferland's avatar Alexandre Ferland
Browse files

Merge pull request #11 from iiSeymour/master

Login redirect to original requested page
parents 42fc823d e5cca7f5
No related branches found
No related tags found
No related merge requests found
...@@ -63,9 +63,9 @@ copyright = u'2014, Alexandre Ferland' ...@@ -63,9 +63,9 @@ copyright = u'2014, Alexandre Ferland'
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = '0.2.0' version = '0.2.1'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.2.0' release = '0.2.1'
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
......
...@@ -108,6 +108,11 @@ History ...@@ -108,6 +108,11 @@ History
Changes: Changes:
- 0.2.1: January 6, 2015
- Fix Github issue `#10 <https://github.com/admiralobvious/flask-simpleldap/issues/10>`_,
Redirect users back to the page they originally requested after authenticating
- 0.2.0: December 7, 2014 - 0.2.0: December 7, 2014
- Added HTTP Basic Authentication. Thanks to OptiverTimAll on GitHub. - Added HTTP Basic Authentication. Thanks to OptiverTimAll on GitHub.
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
__all__ = ['LDAP'] __all__ = ['LDAP']
from functools import wraps
import re import re
import ldap import ldap
from ldap import filter import ldap.filter
from flask import abort, current_app, g, make_response, redirect, url_for, \ from functools import wraps
request from flask import abort, current_app, g, make_response, redirect, url_for, request
try: try:
from flask import _app_ctx_stack as stack from flask import _app_ctx_stack as stack
...@@ -252,7 +250,7 @@ class LDAP(object): ...@@ -252,7 +250,7 @@ class LDAP(object):
@wraps(func) @wraps(func)
def wrapped(*args, **kwargs): def wrapped(*args, **kwargs):
if g.user is None: if g.user is None:
return redirect(url_for(current_app.config['LDAP_LOGIN_VIEW'])) return redirect(url_for(current_app.config['LDAP_LOGIN_VIEW'], next=request.path))
return func(*args, **kwargs) return func(*args, **kwargs)
return wrapped return wrapped
...@@ -277,7 +275,7 @@ class LDAP(object): ...@@ -277,7 +275,7 @@ class LDAP(object):
def wrapped(*args, **kwargs): def wrapped(*args, **kwargs):
if g.user is None: if g.user is None:
return redirect( return redirect(
url_for(current_app.config['LDAP_LOGIN_VIEW'])) url_for(current_app.config['LDAP_LOGIN_VIEW'], next=request.path))
match = [group for group in groups if group in g.ldap_groups] match = [group for group in groups if group in g.ldap_groups]
if not match: if not match:
......
...@@ -9,7 +9,7 @@ from setuptools import setup ...@@ -9,7 +9,7 @@ from setuptools import setup
setup( setup(
name='Flask-SimpleLDAP', name='Flask-SimpleLDAP',
version='0.2.0', version='0.2.1',
url='https://github.com/admiralobvious/flask-simpleldap', url='https://github.com/admiralobvious/flask-simpleldap',
license='MIT', license='MIT',
author='Alexandre Ferland', author='Alexandre Ferland',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment