def before_request(): if current_user.is_authenticated: current_user.ping() if not current_user.confirmed: # todo this should be fixed return redirect(url_for('auth.login'))
def before_request(): #用户已登录、用户的账户还没有确认、请求的对端不在认证蓝本中 if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint[:5] != 'auth.': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ This function will be called before each request is processed :return: -NA- """ if current_user.is_authenticated: current_user.ping()
def before_request(): if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): if current_user.is_authenticated: #: ping is working for update the last_seen field! current_user.ping() if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ This is a hook to the request call. This function will be called before processing the user http request. :return: """ if current_user.is_authenticated: current_user.ping()
def before_request(): # 判断用户是否登录 if current_user.is_authenticated: # 刷新最后登录时间 current_user.ping() if not current_user.confirmed \ and request.endpoint[:5] != 'auth.': return redirect(url_for('auth.unconfirmed'))
def before_request(): """Used to register the users activity, when a request is sent.""" # if current_user.is_authenticated and not current_user.confirmed: # if not ('unconfirmed' in request.url_rule.rule or 'confirm' in request.url_rule.rule): # return redirect(url_for('auth.unconfirmed')) # if current_user.is_authenticated: current_app.logger.debug('User ping (%s).' % (current_user.id)) current_user.ping()
def before_request(): # 用户已登录但未确认且请求的端点不在认证蓝本中 if current_user.is_authenticated: # 更新已登录用户的访问时间 current_user.ping() # endpoint用于获取请求端点 if not current_user.confirmed\ and request.endpoint[:5] != 'auth.'\ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): # before_app_request deal with # each request before it reaches view function if current_user.is_authenticated: current_user.ping() if not current_user.confirmed\ and request.endpoint\ and request.blueprint != 'auth'\ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): # is_authenticated must return True if the users has login credentials if current_user.is_authenticated: current_user.ping() # if it is not yet confirmed. if not current_user.confirmed and request.endpoint[: 5] != 'auth.' and request.endpoint != 'static': # find auth.route('/unconfirmed') return redirect(url_for('auth.unconfirmed'))
def before_request(): logged_in_or_not = is_logged_in(request.remote_addr + request.user_agent.__str__()) if not logged_in_or_not: logout_user() if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and logged_in_or_not: return redirect(url_for('auth.unconfirmed'))
def before_request() -> Any: if current_user.is_authenticated: current_user.ping() if ( not current_user.confirmed and request.endpoint and request.blueprint != "auth" and request.endpoint != "static" ): return redirect(url_for("auth.unconfirmed"))
def before_request(): if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static' \ and request.endpoint != 'bootstrap.static': print(request.endpoint) return redirect(url_for('auth.unconfirmed'))
def before_request(): # if current_user.is_authenticated \ # and not current_user.confirmed \ # and request.endpoint[:5] != 'auth.' \ # and request.endpoint != 'static': # return redirect(url_for('auth.unconfirmed')) if current_user.is_authenticated: current_user.ping() if not current_user.confirmed and request.endpoint[:5] != 'auth.': return redirect(url_for('auth.unconfirmed'))
def before_request(): if current_user.is_authenticated: current_user.ping() print request.endpoint[:5] print request.endpoint print current_user.confirmed if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): ''' @note: 修饰的函数会在请求处理之前被调用 ''' if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and str(request.endpoint[:5]) != 'auth.': #and str(request.endpoint) != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ 设置一个针对程序全局的钩子函数,使其要求在用户获取权限之前先确认账户。 同时满足以下条件时,该函数会拦截用户请求: 用户已经登陆但没有确认,且请求的端点不在auth的蓝本中。 """ if current_user.is_authenticated: current_user.ping() # update time if not current_user.confirmed and request.endpoint[:5] != 'auth.' and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ Function to run before each request in the application to intercept users that are logged in, but not confirmed. """ if current_user.is_authenticated(): current_user.ping() # update 'last_seen' before each request if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): if current_user.is_authenticated: current_user.ping() # if not current_user.confirmed and request.endpoint[:5] != 'auth': if not current_user.confirmed \ and request.endpoint \ and request.blueprint != 'auth' \ and request.endpoint != 'static': #if current_user.is_authenticated() and not current_user.confirmed and request.endpoint[:5] != 'auth.' and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ 设置一个针对程序全局的钩子函数,使其要求在用户获取权限之前先确认账户。 同时满足以下条件时,该函数会拦截用户请求: 用户已经登陆但没有确认,且请求的端点不在auth的蓝本中。 """ if current_user.is_authenticated: current_user.ping() # update time if not current_user.confirmed and request.endpoint[: 5] != 'auth.' and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint \ and request.blueprint != 'auth' \ and request.endpoint != 'main.index' \ and request.endpoint != 'serate.prossime' \ and request.endpoint != 'corsi.lista' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ Filter unconfirmed users by 3 conditions @condition1: User has logged in @condition2: User's account hasn't been confirmed @condition3: Endpoint of the request is not in the auth_blueprint """ if current_user.is_authenticated: current_user.ping() if not current_user.confirmed and request.endpoint[:5] != 'auth.': return redirect(url_for('auth.unconfirmed'))
def before_request(): # atualizar o campo last_seen sempre que o usuário fizer uma requisição if current_user.is_authenticated: current_user.ping() # Caso usuário não esteje confirmado, redireciona para página 'unconfirmed' após atulizar last_seen if not current_user.confirmed \ and request.endpoint \ and request.blueprint != 'auth' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': # print("!!ZZZ1! next={}".format(request.args.get('next'))) # if (request.args.get('next') is not None) and (not request.args.get('next').startswith(r'/auth/confirm')): # return redirect(request.args.get('next')) return redirect(url_for('auth.unconfirmed'))
def before_request(): # 如果用户是认证过的, # 但是confirmed属性为False # 而且,request的网址不是以auth和static开头--------------------------------------> # 就返回到一个未确认的路由 if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """拦截请求,请求之前过滤掉未确认且请求端点不在认证蓝本中的用户请求, 重定向到一个显示给未确认用户的页面 """ if current_user.is_authenticated: current_user.ping() if current_user.is_authenticated \ and not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request( ): # THIS FUNCTION ONLY WORKS WHEN THE NEXT CONDITIONS ARE TRUE: if current_user.is_authenticated: current_user.ping( ) # HERE WE CALL PING METHOD IN ORDER TO UPDATE THE LAST SEEN USER PROPERTY if not current_user.confirmed \ and request.endpoint \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': # THE USER IS AUTHENTICATED, THE CURRENT USER IS NOT CONFIRMED, # AND OTHER THAT IN THIS POINT I DON'T GET WELL return redirect(url_for('auth.unconfirmed'))
def before_request(): '''页面请求预处理''' # current_user 默认为匿名用户,其 is_authenticated 属性值为 False # 用户登录后,current_user 为登录用户,is_authenticated 属性值为 True if current_user.is_authenticated: current_user.ping() # fresh the last_seen # 未验证的用户登录后要发出 POST 请求的话,让用户先通过验证 # 如果用户未通过邮箱确认身份,且为 POST 请求 if (not current_user.confirmed) and (request.method == 'POST'): # 那么把请求交给 front.unconfirmed_user 函数处理 return redirect(url_for('front.unconfirmed_user'))
def before_request(): if current_user.is_authenticated: noti_id = request.args.get('noti', 0, type=int) if noti_id != 0: n = Notification.query.get(noti_id) if n and n.user == current_user: n.mark_read() current_user.ping() if not current_user.confirmed_email and request.endpoint and request.blueprint != 'auth' and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): ''' 功能:请求钩子,拦截不合法用户发起的请求 ''' if current_user.is_authenticated: #如果用户已登录 current_user.ping() #刷新用户最后的访问时间 if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static':#如果用户还未确认,请求的端点不在认证蓝本中,则重定向 return redirect(url_for('auth.unconfirmed'))
def before_request(): '''请求钩子,在请求之前做点事''' if current_user.is_authenticated: # 当前用户已登录 # 更新已登录用户的最后访问时间 current_user.ping() # 如果用户的comfirmed为Flase if not current_user.confirmed \ and request.endpoint \ and request.blueprint != 'auth' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): #如果用户是认证过的 ##用户未确认,not ###request的网址不是以auth.和static开头的?? if current_user.is_authenticated: ###更新已登录用户的访问时间 current_user.ping() if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed')) #返回到未确认的一个路由
def before_request(): """ Декоратор before_app_request перехватит запрос при выполнении всех трех условий """ if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint \ and request.blueprint != 'auth' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): ''' define operation about before request :return: redirect page ''' if current_user.is_authenticated: current_user.ping() if ( not current_user.confirmed ) and request.endpoint[:5] != 'auth.' and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """对属于蓝图auth的每个请求前判断: 若用户已注册(已登录)但还没有confirm,且其访问的页面不是confirm页面或static端节点,重定向到auth.unconfirmed 任何使用了before_request装饰器的函数在接收请求之前都会运行;在蓝图(auth)中需要使用before_app_request; is_authenticated() must return True if the user has login credentials or False otherwise; From a blueprint, the before_request hook applies only to requests that belong to the blueprint.""" if current_user.is_authenticated: current_user.ping() # [IMP] 更新数据库User模型的last_seen属性 g.search_form = SearchForm() # [IMP] 创建搜索表单对象并使得其对所有模版可用,存放在全局变量g中 if not current_user.confirmed \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ 过滤未进行邮件确认的账户,会在请求之前调用 :return: """ if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint \ and request.blueprint != 'auth' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ 满足下列三个条件,before_app_request处理程序会拦截请求 1 用户已登陆 2 用户账户还没有确认 3 请求的端点不在认证蓝本中,访问认证路由要获取权限,\ 因为这些路由的作用是让用户确认账户或执行其他账户管理操作 """ if current_user.is_authenticated: current_user.ping() if not current_user.confirmed and request.endpoint[:5] != 'auth.': return redirect(url_for('auth.unconfirmed'))
def login(): newform=LoginForm() if newform.validate_on_submit(): user=User.query.filter_by(email=newform.email.data).first() if user is not None and user.verify_password(newform.password.data): login_user(user,newform.remember_me.data) if current_user.confirmed is False: return render_template('unconfirmed.html',user=current_user) current_user.ping() return redirect(request.args.get('next') or url_for('user',username=current_user.username)) flash('Invalid Username or Password') return render_template('login.html',form=newform)
def before_request(): """ 如果为验证,则跳转到未验证的引导页 :return: """ if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint \ and request.endpoint[:5] != 'auth.' \ and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): """ before request hook User is registered and logged in, but cannot access app yet because email needs to be confirmed. :return: """ if current_user.is_authenticated: current_user.ping() if not current_user.confirmed \ and request.endpoint[:5] != 'auth.': return redirect(url_for('auth.unconfirmed'))
def before_request(): '''auth.before_request()''' if current_user.is_authenticated: current_user.ping() db.session.commit() ip_address = request.headers.get('X-Forwarded-For', request.remote_addr) if ip_address != current_user.last_seen_ip: current_user.update_ip(ip_address=ip_address) db.session.commit() add_user_log( user=current_user._get_current_object(), event='请求访问(来源:{})'.format(get_geo_info(ip_address=ip_address, show_ip=True)), category='access' ) if not current_user.confirmed and \ not request.endpoint.startswith('auth.') and \ request.endpoint != 'static': return redirect(url_for('auth.unconfirmed'))
def before_request(): ''' 过滤未确认的账户 (1) 用户已登录(current_user.is_authenticated() 必须返回True)。 (2) 用户的账户还未确认。 (3) 请求的端点(使用request.endpoint 获取)不在认证蓝本中。访问认证路由要获取权 限,因为这些路由的作用是让用户确认账户或执行其他账户管理操作。 ''' if current_user.is_authenticated \ and not current_user.confirmed \ and request.endpoint[:5] != 'auth.' and request.endpoint != 'static': return redirect(url_for('auth.unconfirmed')) if current_user.is_authenticated: '''更新已登录用户 的访问时间''' current_user.ping() if not current_user.confirmed and request.endpoint[:5] != 'auth.': return redirect(url_for('auth.unconfirmed'))
def before_request(): if current_user.is_authenticated: current_user.ping()
def before_request(): """Get the last_seen time of user""" if current_user.is_authenticated: current_user.ping()
def before_request(): if current_user.is_authenticated: current_user.ping() if not current_user.confirmed and request.endpoint[:5] != "auth.": return render_template("auth/user_confirm.html", confirmed=False)
def before_request(): if not current_user.is_anonymous(): current_user.ping()
def before_request(): if current_user.is_authenticated: current_user.ping() # Flask-Login 0.3.2: crash, 'AnonymousUserMixin' object has no attribute 'ping' if not current_user.confirmed \ and request.endpoint[:5] != 'auth.': return redirect(url_for('auth.unconfirmed'))
def before_request(): if current_user.is_authenticated: current_user.ping() if not current_user.confirmed and request.endpoint[:5] != "auth.": return redirect(url_for("auth.unconfirmed"))
def index(): current_user.ping() return render_template('index.html')
def before_request(): # P94,拦截请求 if current_user.is_authenticated: # 确保用户已登陆 current_user.ping() # 更新登陆时间