本文整理汇总了Python中social.apps.django_app.views.complete函数的典型用法代码示例。如果您正苦于以下问题:Python complete函数的具体用法?Python complete怎么用?Python complete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了complete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
def register(request):
'''
Registration form.
'''
if appsettings.REGISTRATION_CAPTCHA:
form_class = CaptchaRegistrationForm
else:
form_class = RegistrationForm
if request.method == 'POST':
form = form_class(request.POST)
if form.is_valid() and appsettings.REGISTRATION_OPEN:
return complete(request, 'email')
else:
form = form_class()
backends = load_backends(BACKENDS).keys()
# Redirect if there is only one backend
if len(backends) == 1 and backends[0] != 'email':
return redirect('social:begin', backends[0])
backends = set(backends)
return render(
request,
'accounts/register.html',
{
'registration_email': 'email' in backends,
'registration_backends': backends - set(['email']),
'title': _('User registration'),
'form': form,
}
)
示例2: register
def register(request):
"""
Registration form.
"""
if appsettings.REGISTRATION_CAPTCHA:
form_class = CaptchaRegistrationForm
else:
form_class = RegistrationForm
if request.method == "POST":
form = form_class(request.POST)
if form.is_valid() and appsettings.REGISTRATION_OPEN:
return complete(request, "email")
else:
form = form_class()
backends = set(load_backends(BACKENDS).keys())
return render(
request,
"accounts/register.html",
{
"registration_email": "email" in backends,
"registration_backends": backends - set(["email"]),
"title": _("User registration"),
"form": form,
},
)
示例3: register
def register(request):
"""
Registration form.
"""
if appsettings.REGISTRATION_CAPTCHA:
form_class = CaptchaRegistrationForm
else:
form_class = RegistrationForm
if request.method == "POST":
form = form_class(request.POST)
if form.is_valid() and appsettings.REGISTRATION_OPEN:
return complete(request, "email")
else:
form = form_class()
backends = load_backends(BACKENDS).keys()
# Redirect if there is only one backend
if len(backends) == 1 and backends[0] != "email":
return redirect("social:begin", backends[0])
backends = set(backends)
return render(
request,
"accounts/register.html",
{
"registration_email": "email" in backends,
"registration_backends": backends - set(["email"]),
"title": _("User registration"),
"form": form,
},
)
示例4: reset_password
def reset_password(request):
'''
Password reset handling.
'''
if request.method == 'POST':
form = ResetForm(request.POST)
if form.is_valid():
user = form.cleaned_data['email']
user.set_unusable_password()
user.save()
if not request.session.session_key:
request.session.create()
request.session['password_reset'] = True
return complete(request, 'email')
else:
form = ResetForm()
return render(
request,
'accounts/reset.html',
{
'title': _('Password reset'),
'form': form,
}
)
示例5: reset_password
def reset_password(request):
'''
Password reset handling.
'''
if 'email' not in load_backends(BACKENDS).keys():
messages.error(
request,
_('Can not reset password, email authentication is disabled!')
)
return redirect('login')
if request.method == 'POST':
form = ResetForm(request.POST)
if form.is_valid():
user = form.cleaned_data['email']
user.set_unusable_password()
user.save()
if not request.session.session_key:
request.session.create()
request.session['password_reset'] = True
return complete(request, 'email')
else:
form = ResetForm()
return render(
request,
'accounts/reset.html',
{
'title': _('Password reset'),
'form': form,
}
)
示例6: register
def register(request):
'''
Registration form.
'''
if appsettings.REGISTRATION_CAPTCHA:
form_class = CaptchaRegistrationForm
else:
form_class = RegistrationForm
if request.method == 'POST':
form = form_class(request.POST)
if form.is_valid() and appsettings.REGISTRATION_OPEN:
return complete(request, 'email')
else:
form = form_class()
backends = set(load_backends(BACKENDS).keys())
return render(
request,
'accounts/register.html',
{
'registration_email': 'email' in backends,
'registration_backends': backends - set(['email']),
'title': _('User registration'),
'form': form,
}
)
示例7: get
def get(self, request, *args, **kwargs):
backend = kwargs.pop('backend')
try:
return complete(request, backend, *args, **kwargs)
except AuthFailed:
messages.error(request, "Your domain isn't authorized")
return HttpResponseRedirect(reverse('login'))
示例8: register
def register(request):
"""
Registration form.
"""
if appsettings.REGISTRATION_CAPTCHA:
form_class = CaptchaRegistrationForm
else:
form_class = RegistrationForm
if request.method == "POST":
form = form_class(request.POST)
if form.is_valid() and appsettings.REGISTRATION_OPEN:
return complete(request, "email")
else:
form = form_class()
return render_to_response(
"accounts/register.html",
RequestContext(
request,
{
"registration_backends": [x for x in load_backends(BACKENDS).keys() if x != "email"],
"title": _("User registration"),
"form": form,
},
),
)
示例9: reset_password
def reset_password(request):
"""
Password reset handling.
"""
if "email" not in load_backends(BACKENDS).keys():
messages.error(request, _("Can not reset password, email authentication is disabled!"))
return redirect("login")
if request.method == "POST":
form = ResetForm(request.POST)
if form.is_valid():
user = form.cleaned_data["email"]
user.set_unusable_password()
user.save()
# Force creating new session
request.session.create()
if request.user.is_authenticated():
logout(request)
request.session["password_reset"] = True
return complete(request, "email")
else:
form = ResetForm()
return render(request, "accounts/reset.html", {"title": _("Password reset"), "form": form})
示例10: get
def get(request, *args, **kwargs):
backend = kwargs.pop('backend')
try:
return complete(request, backend, *args, **kwargs)
except AuthFailed:
return HttpResponseRedirect(reverse('login'))
except AuthAlreadyAssociated:
return HttpResponseRedirect(reverse('login'))
示例11: lti_login_and_complete_view
def lti_login_and_complete_view(request, backend, *args, **kwargs):
"""This is a combination login/complete due to LTI being a one step login"""
if request.method != 'POST':
return HttpResponseNotAllowed('POST')
request.backend.start()
return complete(request, backend, *args, **kwargs)
示例12: email_login
def email_login(request):
"""
Connect email.
"""
if request.method == "POST":
form = EmailForm(request.POST)
if form.is_valid():
return complete(request, "email")
else:
form = EmailForm()
return render(request, "accounts/email.html", {"title": _("Register email"), "form": form})
示例13: complete
def complete(self, **kwargs):
# Before we proceed the auth, clear the session to ensure that no
# half-backed registrations are left over (this would result in a
# redirect to extradata after login even if the logged in user has a
# complete profile.
self.request.session.clear()
# Load social strategy to ensure this request looks like a social auth
# request.
self.request.social_strategy = load_strategy(backend='username')
return complete(self.request, 'username', **kwargs)
示例14: reset_password
def reset_password(request):
"""
Password reset handling.
"""
if request.method == "POST":
form = ResetForm(request.POST)
if form.is_valid():
user = form.cleaned_data["email"]
user.set_unusable_password()
user.save()
return complete(request, "email")
else:
form = ResetForm()
return render_to_response(
"accounts/reset.html", RequestContext(request, {"title": _("Password reset"), "form": form})
)
示例15: reset_password
def reset_password(request):
"""
Password reset handling.
"""
if request.method == "POST":
form = ResetForm(request.POST)
if form.is_valid():
user = form.cleaned_data["email"]
user.set_unusable_password()
user.save()
if not request.session.session_key:
request.session.create()
request.session["password_reset"] = True
return complete(request, "email")
else:
form = ResetForm()
return render(request, "accounts/reset.html", {"title": _("Password reset"), "form": form})