本文整理汇总了Python中forum.models.User.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.set_password方法的具体用法?Python User.set_password怎么用?Python User.set_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forum.models.User
的用法示例。
在下文中一共展示了User.set_password方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import set_password [as 别名]
def register(request):
if request.method == 'POST':
form = ClassicRegisterForm(request.POST.copy())
#form = ClassicRegisterForm(request.POST)
logging.info(form)
if form.is_valid():
logging.error(form.cleaned_data)
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
#email = form.cleaned_data['email']
#user_ = User(username=username, email=email)
user_ = User(username=username)
user_.set_password(password)
if User.objects.all().count() == 0:
user_.is_superuser = True
user_.is_staff = True
user_.save()
#UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()
return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
else:
#form = ClassicRegisterForm(initial={'next':'/'})
form = ClassicRegisterForm()
return render_to_response('auth/complete.html', {
'form1': form
}, context_instance=RequestContext(request))
示例2: register
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import set_password [as 别名]
def register(request):
if request.method == 'POST':
form = ClassicRegisterForm(request.POST)
email_feeds_form = SimpleEmailSubscribeForm(request.POST)
if form.is_valid() and email_feeds_form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password1']
email = form.cleaned_data['email']
user_ = User(username=username, email=email)
user_.set_password(password)
if User.objects.all().count() == 0:
user_.is_superuser = True
user_.is_staff = True
user_.save()
UserJoinsAction(user=user_, ip=request.META['REMOTE_ADDR']).save()
if email_feeds_form.cleaned_data['subscribe'] == 'n':
user_.subscription_settings.enable_notifications = False
user_.subscription_settings.save()
return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
else:
form = ClassicRegisterForm(initial={'next':'/'})
email_feeds_form = SimpleEmailSubscribeForm()
return render_to_response('auth/complete.html', {
'form1': form,
'email_feeds_form': email_feeds_form
}, context_instance=RequestContext(request))
示例3: register
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import set_password [as 别名]
def register(request):
if request.method == "POST":
form = ClassicRegisterForm(request.POST)
email_feeds_form = SimpleEmailSubscribeForm(request.POST)
if form.is_valid() and email_feeds_form.is_valid():
username = form.cleaned_data["username"]
password = form.cleaned_data["password1"]
email = form.cleaned_data["email"]
user_ = User(username=username, email=email)
user_.set_password(password)
if User.objects.all().count() == 0:
user_.is_superuser = True
user_.is_staff = True
user_.save()
UserJoinsAction(user=user_, ip=request.META["REMOTE_ADDR"]).save()
if email_feeds_form.cleaned_data["subscribe"] == "n":
user_.subscription_settings.enable_notifications = False
user_.subscription_settings.save()
return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
else:
form = ClassicRegisterForm(initial={"next": "/"})
email_feeds_form = SimpleEmailSubscribeForm()
return render_to_response(
"auth/complete.html",
{"form1": form, "email_feeds_form": email_feeds_form},
context_instance=RequestContext(request),
)
示例4: register
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import set_password [as 别名]
def register(request):
banned_ips = cache.get(BANNED_IPS_KEY, set())
ip = get_client_ip(request)
if ip in banned_ips:
logging.warning("Spammer returned ip:%s" % ip)
return HttpResponseRedirect("http://www.pudelek.pl/artykul/x/")
if request.method == "POST":
banned_emails = cache.get(BANNED_EMAILS_KEY, set())
if request.POST["email"] in banned_emails:
logging.warning("Spammer returned:%s, ip:%s" % (request.POST["email"], ip))
return HttpResponseRedirect("http://www.pudelek.pl/artykul/x/")
form = ClassicRegisterForm(request.POST)
if form.is_valid():
username = form.cleaned_data["username"]
password = form.cleaned_data["password1"]
email = form.cleaned_data["email"]
# Honeypot checks
if request.POST.get("age", None):
logging.warning("Age honeypot filled, will not register for email:%s, ip:%s" % (email, ip))
ban(email, ip)
return HttpResponseRedirect(reverse("index"))
if request.POST.get("birthday", None):
logging.warning("Birthday honeypot filled, will not register for email:%s, ip:%s" % (email, ip))
ban(email, ip)
return HttpResponseRedirect(reverse("index"))
if request.POST.get("website", None):
logging.warning("Website honeypot filled, will not register for email:%s, ip:%s" % (email, ip))
ban(email, ip)
return HttpResponseRedirect(reverse("index"))
user_ = User(username=username, email=email)
user_.set_password(password)
if User.objects.all().count() == 0:
user_.is_superuser = True
user_.is_staff = True
user_.save()
UserJoinsAction(user=user_, ip=request.META["REMOTE_ADDR"]).save()
logging.info("New user joined with email:%s from ip:%s" % (email, ip))
return login_and_forward(request, user_, None, _("A welcome email has been sent to your email address. "))
else:
form = ClassicRegisterForm(initial={"next": "/"})
return render_to_response(
"auth/register.html",
{"form1": form, "bigicon_providers": _get_bigicon_providers(request)},
context_instance=RequestContext(request),
)
示例5: register
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import set_password [as 别名]
def register(request):
email = request.POST['emailRegister']
if validateEmail(email):
user = User(email = email,display_name = email)
user.save();
raw_password = randint(1000000,9999999)
user.set_password(str(raw_password))
user.save()
send_mail('Welcome to Claremont Academia!','You temporary password is '+ str(raw_password) +'.', \
'[email protected]',[email],fail_silently=False)
return redirect('/login/')
else: return render(request,'loginpage.html',{'invalid_email':True})
示例6: create_user
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import set_password [as 别名]
def create_user(request):
if request.POST:
form = CreateUserForm(request.POST)
if form.is_valid():
user_ = User(username=form.cleaned_data['username'], email=form.cleaned_data['email'])
user_.set_password(form.cleaned_data['password1'])
if not form.cleaned_data.get('validate_email', False):
user_.email_isvalid = True
user_.save()
UserJoinsAction(user=user_).save()
request.user.message_set.create(message=_("New user created sucessfully. %s.") % html.hyperlink(
user_.get_profile_url(), _("See %s profile") % user_.username, target="_blank"))
return HttpResponseRedirect(reverse("admin_tools", kwargs={'name': 'createuser'}))
else:
form = CreateUserForm()
return ('osqaadmin/createuser.html', {
'form': form,
})
示例7: create_user
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import set_password [as 别名]
def create_user(request):
if request.POST:
form = CreateUserForm(request.POST)
if form.is_valid():
user_ = User(username=form.cleaned_data["username"], email=form.cleaned_data["email"])
user_.set_password(form.cleaned_data["password1"])
if not form.cleaned_data.get("validate_email", False):
user_.email_isvalid = True
user_.save()
UserJoinsAction(user=user_).save()
request.user.message_set.create(
message=_("New user created sucessfully. %s.")
% html.hyperlink(user_.get_profile_url(), _("See %s profile") % user_.username, target="_blank")
)
return HttpResponseRedirect(reverse("admin_tools", kwargs={"name": "createuser"}))
else:
form = CreateUserForm()
return ("podporaadmin/createuser.html", {"form": form})