当前位置: 首页>>代码示例>>Python>>正文


Python User.set_password方法代码示例

本文整理汇总了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))
开发者ID:zhigoo,项目名称:osqa-server,代码行数:32,代码来源:views.py

示例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))
开发者ID:p2pu,项目名称:osqa-badges,代码行数:35,代码来源:views.py

示例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),
    )
开发者ID:yangjiandong,项目名称:zhimaq,代码行数:37,代码来源:views.py

示例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),
    )
开发者ID:konrado0,项目名称:vosqa,代码行数:57,代码来源:views.py

示例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})
开发者ID:ClaremontAcademia,项目名称:Forum,代码行数:14,代码来源:views.py

示例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,
    })
开发者ID:justingrant,项目名称:OSQAmirror,代码行数:26,代码来源:admin.py

示例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})
开发者ID:podpora,项目名称:podpora,代码行数:26,代码来源:admin.py


注:本文中的forum.models.User.set_password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。