本文整理汇总了Python中forum.authentication.AUTH_PROVIDERS.values方法的典型用法代码示例。如果您正苦于以下问题:Python AUTH_PROVIDERS.values方法的具体用法?Python AUTH_PROVIDERS.values怎么用?Python AUTH_PROVIDERS.values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forum.authentication.AUTH_PROVIDERS
的用法示例。
在下文中一共展示了AUTH_PROVIDERS.values方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_bigicon_providers
# 需要导入模块: from forum.authentication import AUTH_PROVIDERS [as 别名]
# 或者: from forum.authentication.AUTH_PROVIDERS import values [as 别名]
def _get_bigicon_providers(request):
all_providers = [provider.context for provider in AUTH_PROVIDERS.values() if provider.context]
sort = lambda c1, c2: c1.weight - c2.weight
can_show = lambda c: not request.user.is_authenticated() or c.show_to_logged_in_user
return sorted([context for context in all_providers if context.mode == "BIGICON" and can_show(context)], sort)
示例2: signin_page
# 需要导入模块: from forum.authentication import AUTH_PROVIDERS [as 别名]
# 或者: from forum.authentication.AUTH_PROVIDERS import values [as 别名]
def signin_page(request):
subdomain = get_subdomain()
on_hub_server = not any(map(lambda x: subdomain.endswith(x), ['-a', '-b']))
if not on_hub_server and not request.session.has_key('auth_error'):
# Go log in to main site instead, which will redirect back here
return HttpResponseRedirect('http://' + subdomain.replace('-a','').replace('-b', '') + '.moocforums.org' + reverse('auth_signin'))
referer = request.META.get('HTTP_REFERER', '/')
# If the referer is equal to the sign up page, e. g. if the previous login attempt was not successful we do not
# change the sign in URL. The user should go to the same page.
if not referer.replace(settings.APP_URL, '') == reverse('auth_signin'):
request.session[ON_SIGNIN_SESSION_ATTR] = referer
all_providers = [provider.context for provider in AUTH_PROVIDERS.values() if provider.context]
sort = lambda c1, c2: c1.weight - c2.weight
can_show = lambda c: not request.user.is_authenticated() or c.show_to_logged_in_user
if on_hub_server:
bigicon_providers = sorted([
context for context in all_providers if context.mode == 'BIGICON' and can_show(context)
], sort)
else:
bigicon_providers = []
smallicon_providers = sorted([
context for context in all_providers if context.mode == 'SMALLICON' and can_show(context)
], sort)
top_stackitem_providers = sorted([
context for context in all_providers if context.mode == 'TOP_STACK_ITEM' and can_show(context)
], sort)
stackitem_providers = sorted([
context for context in all_providers if context.mode == 'STACK_ITEM' and can_show(context)
], sort)
try:
msg = request.session['auth_error']
del request.session['auth_error']
except:
msg = None
return render_to_response(
'auth/signin.html',
{
'msg': msg,
'all_providers': all_providers,
'bigicon_providers': bigicon_providers,
'top_stackitem_providers': top_stackitem_providers,
'stackitem_providers': stackitem_providers,
'smallicon_providers': smallicon_providers,
},
RequestContext(request))
示例3: signin_page
# 需要导入模块: from forum.authentication import AUTH_PROVIDERS [as 别名]
# 或者: from forum.authentication.AUTH_PROVIDERS import values [as 别名]
def signin_page(request):
referer = request.META.get('HTTP_REFERER', '/')
# If the referer is equal to the sign up page, e. g. if the previous login attempt was not successful we do not
# change the sign in URL. The user should go to the same page.
if not referer.replace(settings.APP_URL, '') == reverse('auth_signin'):
request.session[ON_SIGNIN_SESSION_ATTR] = referer
all_providers = [provider.context for provider in AUTH_PROVIDERS.values() if provider.context]
sort = lambda c1, c2: c1.weight - c2.weight
can_show = lambda c: not request.user.is_authenticated() or c.show_to_logged_in_user
bigicon_providers = sorted([
context for context in all_providers if context.mode == 'BIGICON' and can_show(context)
], sort)
smallicon_providers = sorted([
context for context in all_providers if context.mode == 'SMALLICON' and can_show(context)
], sort)
top_stackitem_providers = sorted([
context for context in all_providers if context.mode == 'TOP_STACK_ITEM' and can_show(context)
], sort)
stackitem_providers = sorted([
context for context in all_providers if context.mode == 'STACK_ITEM' and can_show(context)
], sort)
allow_auto_redirect = "true"
if request.user.is_authenticated():
allow_auto_redirect = "false"
try:
msg = request.session['auth_error']
del request.session['auth_error']
allow_auto_redirect = "false"
except:
msg = None
return render_to_response(
'auth/signin.html',
{
'msg': msg,
'bz_url': djsettings.BZ_SITE_BASE,
'allow_auto_redirect': allow_auto_redirect,
'all_providers': all_providers,
'bigicon_providers': bigicon_providers,
'top_stackitem_providers': top_stackitem_providers,
'stackitem_providers': stackitem_providers,
'smallicon_providers': smallicon_providers,
},
RequestContext(request))
示例4: signin_page
# 需要导入模块: from forum.authentication import AUTH_PROVIDERS [as 别名]
# 或者: from forum.authentication.AUTH_PROVIDERS import values [as 别名]
def signin_page(request):
referer = request.META.get('HTTP_REFERER', reverse('index'))
referer_parsed = urlparse(referer)
# If the referer is equal to the sign up page, e. g. if the previous login attempt was not successful we do not
# change the sign in URL. The user should go to the same page.
### F. CRESPEL EDIT 2013-01-26: reworked condition to work with HTTP/HTTPS and prevent redirecting to off-site URL
if not referer_parsed.path == reverse('auth_signin') and urlparse(settings.APP_URL).path in referer_parsed.path:
request.session[ON_SIGNIN_SESSION_ATTR] = referer
all_providers = [provider.context for provider in AUTH_PROVIDERS.values() if provider.context]
sort = lambda c1, c2: c1.weight - c2.weight
can_show = lambda c: not request.user.is_authenticated() or c.show_to_logged_in_user
bigicon_providers = sorted([
context for context in all_providers if context.mode == 'BIGICON' and can_show(context)
], sort)
smallicon_providers = sorted([
context for context in all_providers if context.mode == 'SMALLICON' and can_show(context)
], sort)
top_stackitem_providers = sorted([
context for context in all_providers if context.mode == 'TOP_STACK_ITEM' and can_show(context)
], sort)
stackitem_providers = sorted([
context for context in all_providers if context.mode == 'STACK_ITEM' and can_show(context)
], sort)
try:
msg = request.session['auth_error']
del request.session['auth_error']
except:
msg = None
# F. CRESPEL EDIT 2013-01-28: added setting to redirect to a default authentication provider
if settings.DEFAULT_AUTH_PROVIDER and not msg:
return HttpResponseRedirect(reverse('auth_provider_signin', kwargs={'provider': str(settings.DEFAULT_AUTH_PROVIDER)}))
return render_to_response(
'auth/signin.html',
{
'msg': msg,
'all_providers': all_providers,
'bigicon_providers': bigicon_providers,
'top_stackitem_providers': top_stackitem_providers,
'stackitem_providers': stackitem_providers,
'smallicon_providers': smallicon_providers,
},
RequestContext(request))
示例5: signin_page
# 需要导入模块: from forum.authentication import AUTH_PROVIDERS [as 别名]
# 或者: from forum.authentication.AUTH_PROVIDERS import values [as 别名]
def signin_page(request):
referer = request.META.get("HTTP_REFERER", "/")
# If the referer is equal to the sign up page, e. g. if the previous login attempt was not successful we do not
# change the sign in URL. The user should go to the same page.
if not referer.replace(settings.APP_URL, "") == reverse("auth_signin"):
request.session[ON_SIGNIN_SESSION_ATTR] = referer
all_providers = [provider.context for provider in AUTH_PROVIDERS.values() if provider.context]
sort = lambda c1, c2: c1.weight - c2.weight
can_show = lambda c: not request.user.is_authenticated() or c.show_to_logged_in_user
bigicon_providers = sorted(
[context for context in all_providers if context.mode == "BIGICON" and can_show(context)], sort
)
smallicon_providers = sorted(
[context for context in all_providers if context.mode == "SMALLICON" and can_show(context)], sort
)
top_stackitem_providers = sorted(
[context for context in all_providers if context.mode == "TOP_STACK_ITEM" and can_show(context)], sort
)
stackitem_providers = sorted(
[context for context in all_providers if context.mode == "STACK_ITEM" and can_show(context)], sort
)
try:
msg = request.session["auth_error"]
del request.session["auth_error"]
except:
msg = None
return render_to_response(
"auth/signin.html",
{
"msg": msg,
"all_providers": all_providers,
"bigicon_providers": bigicon_providers,
"top_stackitem_providers": top_stackitem_providers,
"stackitem_providers": stackitem_providers,
"smallicon_providers": smallicon_providers,
},
RequestContext(request),
)
示例6: signin_page
# 需要导入模块: from forum.authentication import AUTH_PROVIDERS [as 别名]
# 或者: from forum.authentication.AUTH_PROVIDERS import values [as 别名]
def signin_page(request, action=None):
if action is None:
request.session['on_signin_url'] = request.META.get('HTTP_REFERER', '/')
else:
request.session['on_signin_action'] = action
request.session['on_signin_url'] = reverse('auth_action_signin', kwargs={'action': action})
all_providers = [provider.context for provider in AUTH_PROVIDERS.values()]
sort = lambda c1, c2: c1.weight - c2.weight
can_show = lambda c: not request.user.is_authenticated() or c.show_to_logged_in_user
bigicon_providers = sorted([
context for context in all_providers if context.mode == 'BIGICON' and can_show(context)
], sort)
smallicon_providers = sorted([
context for context in all_providers if context.mode == 'SMALLICON' and can_show(context)
], sort)
top_stackitem_providers = sorted([
context for context in all_providers if context.mode == 'TOP_STACK_ITEM' and can_show(context)
], sort)
stackitem_providers = sorted([
context for context in all_providers if context.mode == 'STACK_ITEM' and can_show(context)
], sort)
try:
msg = request.session['auth_error']
del request.session['auth_error']
except:
msg = None
return render_to_response(
'auth/signin.html',
{
'msg': msg,
'all_providers': all_providers,
'bigicon_providers': bigicon_providers,
'top_stackitem_providers': top_stackitem_providers,
'stackitem_providers': stackitem_providers,
'smallicon_providers': smallicon_providers,
},
RequestContext(request))