Last active
May 14, 2016 07:57
-
-
Save awanabe/5261048bec893100465a38da410d354c to your computer and use it in GitHub Desktop.
flask require_no_login_wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def require_no_login(f): | |
@wraps(f) | |
def wrapper(*args, **kwargs): | |
if current_user.is_authenticated: | |
if request.method == 'POST': | |
return jsonify(success=False, error_msg='已经登录') | |
return redirect('/') | |
return f(*args, **kwargs) | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment