如果会话存在,跳过登录页

2024-04-24 09:42:03 发布

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

如果Flask应用程序中存在活动会话,如何跳过登录页面。在

目前我有烧瓶应用程序,成功登录后,正在重定向页面到索引-

http://example.com/-->;登录后-->;http://example.com/index(成功)

但是,当活动会话存在时,当我尝试http://example.com/时,我需要再次登录页面。在


Tags: gtcom应用程序httpflaskindex烧瓶example
1条回答
网友
1楼 · 发布于 2024-04-24 09:42:03

在登录处理程序中,只需检查用户是否在函数的早期登录。例如,如果使用Flask登录:

def login():
    if current_user.is_authenticated():
        return redirect(url_for('index'))
    # process login for anon user

相关问题 更多 >