def before_request(): if current_user.is_authenticated() and current_user.is_user() and not current_user.active: logout_user() error(msg=Item.data('active_alert_text', '你的帐号已被封号处理!', name='封号提示')) if current_user.is_authenticated() \ and request.endpoint not in current_app.user_manager.config.allow_oauth_urls \ and not request.path.startswith('/admin'): um = current_app.user_manager model = um.config.oauth_model remember = um.config.oauth_remember um.models.User.heart() if not current_user.is_user(): if model == 'auto': user = um.models.User.from_oauth(current_user) login_user(user, remember=remember) return elif current_user.phone or current_user.email or model == 'auto': return if is_json(): abort(NEED_BIND) query = urlencode(dict(next=request.url)) return redirect('%s?%s' % (current_app.user_manager.config.bind_url, query))
def before_request(): if current_user.is_authenticated() and 'channel' in str( current_user.get_id()): return if current_user.is_authenticated() and current_user.is_user( ) and not current_user.active: logout_user() error( msg=Item.data('active_alert_text', '你的帐号已被封号处理!', name='封号提示')) if current_user.is_authenticated() \ and request.endpoint not in current_app.user_manager.config.allow_oauth_urls \ and not request.path.startswith('/admin'): um = current_app.user_manager model = um.config.oauth_model remember = um.config.oauth_remember um.models.User.heart() if not current_user.is_user(): if model == 'auto': user = um.models.User.from_oauth(current_user) login_user(user, remember=remember) return elif current_user.phone or current_user.email or model == 'auto': return if is_json(): abort(NEED_BIND) query = urlencode(dict(next=request.url)) return redirect('%s?%s' % (current_app.user_manager.config.bind_url, query))
def before_request(): if current_user.is_authenticated() and not current_user.is_user() \ and request.endpoint not in current_app.user_manager.config.allow_oauth_urls: model = current_app.user_manager.config.oauth_model remember = current_app.user_manager.config.oauth_remember if model == 'auto': user = um.models.User.from_oauth(current_user) login_user(user, remember=remember) if is_json(): abort(NEED_BIND) print request.endpoint return redirect(current_app.user_manager.config.bind_url)
def wxauth_error(err, action, next): if is_json(): abort(WXAUTH_ERROR, wxcode=err, wxmsg=wxauth.MSGS.get(err, '未知错误')) return error('微信授权失败')