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


Python User.password方法代码示例

本文整理汇总了Python中user.models.User.password方法的典型用法代码示例。如果您正苦于以下问题:Python User.password方法的具体用法?Python User.password怎么用?Python User.password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在user.models.User的用法示例。


在下文中一共展示了User.password方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import password [as 别名]
 def post(self):
     context = self.get_context()
     form = context.get('form')
     
     if form.validate():
         user = User()
         form.populate_obj(user)
         user.password = str(flask_bcrypt.generate_password_hash(user.password),'utf-8')
         user.save()
         return redirect(url_for('user.login'))
     
     flash('Your request failed to pass','newAccount')
     return redirect(url_for('user.new'))
开发者ID:woosungchu,项目名称:heroku-resume,代码行数:15,代码来源:views.py

示例2: _add_user

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import password [as 别名]
def _add_user(request, email, password, band_id, facebook = "", name = "", country = ""):
    #import ipdb; ipdb.set_trace()
    key = hashlib.md5(email).hexdigest()

    try:
        country = Country.objects.get(id=country)
    except:
        country = Country.objects.get(id=1)

    if not facebook:
        confirmed = 0
        try:
            html = "Hello!"
            html = html + "<br><br>To confirm your vote "
            html = html + "<a href='http://rockranking.com/user/validate/" + key + "/'>click here</a>"
            html = html + "<br><br>If you can not access the link, please copy this"
            html = html + "<br>http://rockranking.com/user/validate/" + key + "/"
            html = html + "<br>and paste in your browser"
            html = html + "<br><br>Rock Ranking Team \m/"

            _send_email(email,html)
            email_feedback = 'sent'
        except:
            email_feedback = 'error to sent'
    else:
        confirmed = 1
        email_feedback = 'facebook login'
    try:
        user = User()
        user.username = ""
        user.name = name
        user.email = email
        user.password = hashlib.md5(password).hexdigest()
        user.email_feedback = email_feedback
        user.facebook = facebook
        user.country = country
        user.ip = request.META.get('REMOTE_ADDR')
        user.key = key
        user.date = datetime.now()
        user.action = "add_band_%s" % band_id
        user.confirmed = confirmed
        user.save()

        return True

    except:
        return False
开发者ID:allanjuliani,项目名称:rockranking,代码行数:49,代码来源:views.py

示例3: edit_user

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import password [as 别名]
def edit_user(user, session=None):
    if not user.isawiz:
        return

    cls()
    username = search()
    shuser = show(username, session)
    if shuser is None:
        shuser = User(username)
    print("\nEditing : {}\n".format(username))
    try:
        shuser.username = edit_field("Name: ", shuser.username)
        shuser.password = edit_field("Password: ", shuser.password)
        shuser.save(session)
        print("{} saved".format(shuser.username))
    except AssertionError as e:
        print(e)
        print("Changes not saved")
开发者ID:d2emon,项目名称:abermud,代码行数:20,代码来源:talker.py

示例4: join

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import password [as 别名]
def join(request):

    user = User()
    user.name = request.POST['name']
    user.email = request.POST['email']
    user.password = request.POST['password']
    user.gender = request.POST['gender']

    if User.objects.filter(email = user.email).exists() is not True:
        user.save()
        return HttpResponseRedirect('/user/joinsuccess')

    # 입력폼 비교 구문과 이에따른 메시지 생성을 별도의 함수내에 구현하고, 그 수행 결과에 따른 action 만을
    # 본 함수에서 구현하도록 한다.

    # 응답으로 되돌려줄 리턴 값은
    # email_available, user의 폼 입력 값들, 응답할 메시지
    # 세 가지로 한다.

    # elif len(User.objects.filter(email = user.email)) == 0:
    #     return render(request, 'user/joinform.html', {"email_availability": False, "user": user})
    else:
        return render(request, 'user/joinform.html', {"email_availability" : False, "user":user})
开发者ID:bitacademy-howl,项目名称:mysite,代码行数:25,代码来源:views.py

示例5: register

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import password [as 别名]
def register(request):
    if request.method == "POST":
        rst = json.loads(request.body.decode("utf-8"))
        uf = UserForm(rst)
        if uf.is_valid():
            #检测用户是否存在
            checkUser = User.objects.filter(email__exact = uf.cleaned_data['email']).first()
            if checkUser:
                data = {}
                data["status"] = 'error'
                data['msg'] = "此Email账户已存在"
                return HttpResponse(json.dumps(data), content_type="application/json")
            user = User()
            user.username = uf.cleaned_data['username']
            pwd = (uf.cleaned_data['password'] + keyPwd).encode("utf-8")
            user.password = hashlib.sha1(pwd).hexdigest()
            user.qq = uf.cleaned_data['qq']
            user.email = uf.cleaned_data['email']
            user.random = ''.join(random.sample(string.ascii_letters + string.digits, 10))
            user.save()

            data = {}
            data["status"] = 'success'
            data['msg'] = ""
            return HttpResponse(json.dumps(data), content_type="application/json")
        else:
            data = {}
            data["status"] = 'error'
            data['msg'] = "Illegal post"
            return HttpResponse(json.dumps(data), content_type="application/json")
    else:
        data = {}
        data["status"] = 'error'
        data['msg'] = "Only post method"

        return HttpResponse(json.dumps(data), content_type="application/json")
开发者ID:FrancisKong,项目名称:QQ-Group-Job,代码行数:38,代码来源:views.py


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