def changeemail(request): """ changeemail view. It require password or openid to allow change. url: /email/* template : authopenid/changeemail.html """ msg = request.GET.get('msg', '') extension_args = {} user_ = request.user redirect_to = get_url_host(request) + reverse('user_changeemail') action = 'change' if request.POST: form = ChangeemailForm(request.POST, user=user_) if form.is_valid(): if not form.test_openid: new_email = form.cleaned_data['email'] if new_email != user_.email: if settings.EMAIL_VALIDATION == 'on': action = 'validate' else: action = 'done_novalidate' set_new_email(user_, new_email, nomessage=True) else: action = 'keep' else: #what does this branch do? return server_error('') request.session['new_email'] = form.cleaned_data['email'] return ask_openid(request, form.cleaned_data['password'], redirect_to, on_failure=emailopenid_failure) elif not request.POST and 'openid.mode' in request.GET: return complete(request, emailopenid_success, emailopenid_failure, redirect_to) else: form = ChangeemailForm(initial={'email': user_.email}, user=user_) output = render('authopenid/changeemail.html', { 'form': form, 'email': user_.email, 'action_type': action, 'msg': msg }, context_instance=RequestContext(request)) if action == 'validate': set_email_validation_message(user_) return output
def changeemail(request): """ changeemail view. It require password or openid to allow change. url: /email/* template : authopenid/changeemail.html """ msg = request.GET.get('msg', '') extension_args = {} user_ = request.user redirect_to = get_url_host(request) + reverse('user_changeemail') action = 'change' if request.POST: form = ChangeemailForm(request.POST, user=user_) if form.is_valid(): if not form.test_openid: new_email = form.cleaned_data['email'] if new_email != user_.email: if settings.EMAIL_VALIDATION == 'on': action = 'validate' else: action = 'done_novalidate' set_new_email(user_, new_email,nomessage=True) else: action = 'keep' else: #what does this branch do? return server_error('') request.session['new_email'] = form.cleaned_data['email'] return ask_openid(request, form.cleaned_data['password'], redirect_to, on_failure=emailopenid_failure) elif not request.POST and 'openid.mode' in request.GET: return complete(request, emailopenid_success, emailopenid_failure, redirect_to) else: form = ChangeemailForm(initial={'email': user_.email}, user=user_) output = render('authopenid/changeemail.html', { 'form': form, 'email': user_.email, 'action_type': action, 'msg': msg }, context_instance=RequestContext(request)) if action == 'validate': set_email_validation_message(user_) return output
def changeemail(request): """ changeemail view. It require password or openid to allow change. url: /email/* template : authopenid/changeemail.html """ msg = request.GET.get("msg", "") extension_args = {} user_ = request.user redirect_to = get_url_host(request) + reverse("user_changeemail") action = "change" if request.POST: form = ChangeemailForm(request.POST, user=user_) if form.is_valid(): if not form.test_openid: new_email = form.cleaned_data["email"] if new_email != user_.email: if settings.EMAIL_VALIDATION == "on": action = "validate" else: action = "done_novalidate" set_new_email(user_, new_email, nomessage=True) else: action = "keep" else: # what does this branch do? return server_error("") request.session["new_email"] = form.cleaned_data["email"] return ask_openid(request, form.cleaned_data["password"], redirect_to, on_failure=emailopenid_failure) elif not request.POST and "openid.mode" in request.GET: return complete(request, emailopenid_success, emailopenid_failure, redirect_to) else: form = ChangeemailForm(initial={"email": user_.email}, user=user_) output = render( "authopenid/changeemail.html", {"form": form, "email": user_.email, "action_type": action, "msg": msg}, context_instance=RequestContext(request), ) if action == "validate": set_email_validation_message(user_) return output
def changeemail(request): """ changeemail view. It require password or openid to allow change. url: /changeemail/ template : authopenid/changeemail.html """ msg = request.GET.get('msg', '') extension_args = {} user_ = request.user redirect_to = get_url_host(request) + reverse('user_changeemail') if request.POST: form = ChangeemailForm(request.POST, user=user_) if form.is_valid(): if not form.test_openid: user_.email = form.cleaned_data['email'] user_.save() msg = _("Email changed.") redirect = "%s?msg=%s" % (reverse('user_account_settings'), urlquote_plus(msg)) return HttpResponseRedirect(redirect) else: request.session['new_email'] = form.cleaned_data['email'] return ask_openid(request, form.cleaned_data['password'], redirect_to, on_failure=emailopenid_failure) elif not request.POST and 'openid.mode' in request.GET: return complete(request, emailopenid_success, emailopenid_failure, redirect_to) else: form = ChangeemailForm(initial={'email': user_.email}, user=user_) return render('authopenid/changeemail.html', { 'form': form, 'msg': msg }, context_instance=RequestContext(request))