You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in the actual documentation the login_callback does not return, and that seems to cause a lot of problems. While it is ok to just render a template (login_ok) or redirect to '/', a simple decorator could be included in the doc to have a more general case, like:
@sso.login_handler
def login_callback(user_info):
"""Store login information in session."""
session['user'] = user_info
return redirect(request.args.get('next_url'))
def sso_required(f):
@wraps(f)
def decorated_function(*args, **kwargs):
if 'user' not in session:
return redirect(url_for('sso_login', next_url=request.url))
return f(*args, **kwargs)
return decorated_function
then you can decorate whatever view function that requires authentication with some added value:
you do not have to actually check for user auth each time
you can use session['user'] being certain that it will be available
you'll be redirected to the url you actually asked for
The text was updated successfully, but these errors were encountered:
daserzw
changed the title
login_callback should return and add a decorator to the doc
login_callback should return and why not add a decorator to the doc
Oct 26, 2016
Hi,
in the actual documentation the
login_callback
does not return, and that seems to cause a lot of problems. While it is ok to just render a template (login_ok) or redirect to '/', a simple decorator could be included in the doc to have a more general case, like:then you can decorate whatever view function that requires authentication with some added value:
Example:
The text was updated successfully, but these errors were encountered: