FlaskLogin用户显然是匿名的

2024-04-19 14:52:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下看法:

@app.route('/write-blog-post', methods=['POST', 'GET'])
@app.route('/<userID>/write-blog-post', methods=['POST', 'GET'])
def writePost(userID=None):

    if not current_user.is_anonymous() and userID != None:
        if current_user.id == int(userID):
            ...
    ...

由于某些原因,当用户使用Flask登录登录时,因此if not current_user.is_anonymous()是{},并且他们使用userID转到URL,我收到一个错误,说明:

^{pr2}$

我在其他视图上使用current_user.id,它成功地工作了。我认为唯一可能导致错误的是视图的多个url可能会干扰某些内容。在

奇怪的是,即使用户同时传递了这两个if语句,函数仍然照常继续。在

有什么问题吗?谢谢。在


Tags: noneappgetifisnotblogcurrent