Python登录多解决方案 [英] Python Login Multi Solution
问题描述
在阅读了很多文章之后,我来到这里问一个与不同类型的用户(两个 usermixin类
)进行烧瓶登录有关的问题.
After reading a lot of articles I came here to ask a question related to flask login with different types of users(two usermixin classes
).
我有2种类型的用户(如上述两个用户类别)-1.让我们将其称为常规用户(电子邮件和密码)2.社交网络用户(Facebook,Twitter,Google),并在成功执行 OAuth
使用 Facebook
, Twitter
和 Google API
登录我需要禁用对个人资料页面的访问(普通用户可以访问),并且当然保持登录状态并稍后注销.
I have 2 types of users(as mentioned two user classes) - 1.Let’s call them regular users(email and password) 2.Social Network users(Facebook, Twitter, Google) and after a successful OAuth
login with Facebook
, Twitter
and Google API
I need to disable access to the profile page(regular users have access) and off course to stay logged and log them out later.
这就是问题,我尝试使用 https://pypi.org/project/Flask-Login-Multi/.很简单,我为auth.py制作了2个蓝图,在其中我为两种类型的用户定义了登录名,但是它不起作用(当我输入 @login_required
时会崩溃)
Here is the thing, I tried with https://pypi.org/project/Flask-Login-Multi/. Simple, I made 2 blueprints for auth.py where I defined logins for both types of users but it is not working(it crashes when I put @login_required
)
我可以在这里提供我的代码,但我只希望有人在可能的情况下为我提供帮助?预先感谢,问候.
I can provide my code here but I just want someone to help me with this if possible? Thanks in advance, regards.
推荐答案
Flask负责人
完成了任务,要说的另一件事是,我需要在会话中定义登录类型为两种类型的用户(常规和社交网络)有条件的 Flask登录
.
Flask principal
with roles did the job and one more important thing to say is that I needed to define a login type in the session in order to have a conditional Flask login
for both types of users(regular and social network).
这篇关于Python登录多解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!