检查当前用户是否使用任何django社交身份验证提供程序登录 [英] Check if current user is logged in using any django social auth provider

查看:59
本文介绍了检查当前用户是否使用任何django社交身份验证提供程序登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查用户是否通过社交身份验证或使用django默认身份验证登录。

I would like to check if a user is logged in via social authentication or using the django default authentication.

类似

如果user.social_auth = true?

if user.social_auth = true?

推荐答案

确定了一些研究之后,我想出了这个解决方案确保用户是使用任何社交提供程序还是仅使用默认的Django身份验证进行身份验证。在此处查看更多信息。

Ok after doing some research i came up with this solution to make sure if a user is authenticated using any social provider or just the default django auth. Check here for moreinfo..

 {% if user.is_authenticated and not backends.associated %}

 #Do or show something if user is not authenticated with social provider but default auth

 {% elif user.is_authenticated and backends.associated %}

  #Do or show something if user is authenticated with social provider

 {% else %}

 #Do or show something if none of both

 {% endif %}

这篇关于检查当前用户是否使用任何django社交身份验证提供程序登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆