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


Python User.verify_password方法代码示例

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


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

示例1: test_User_BlankPassword

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
 def test_User_BlankPassword(self):
   user_email = utilities.fake.free_email()
   user_password = utilities.fake.password()
   user = User()
   user.email = user_email
   user.uuid = utilities.generate_UUID()
   user.save()
   with self.assertRaises(TypeError):
     user.verify_password(user_password)
开发者ID:jrigden,项目名称:muckamuck,代码行数:11,代码来源:test_models.py

示例2: test_verify_password

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
def test_verify_password():
    user = User()
    user.username = u"test"
    user.set_password('test1234')

    user.save()

    assert user.verify_password('test1234')
    assert not user.verify_password('test')
开发者ID:fernandotakai,项目名称:questions,代码行数:11,代码来源:user_tests.py

示例3: test_User_Password

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
 def test_User_Password(self):
   user_email = utilities.fake.free_email()
   user_password = utilities.fake.password()
   user = User()
   user.email = user_email
   user.encrypt_password(user_password)
   user.uuid = utilities.generate_UUID()
   user.save()
   self.assertTrue(user.verify_password(user_password))
开发者ID:jrigden,项目名称:muckamuck,代码行数:11,代码来源:test_models.py

示例4: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
def login():
	form = LoginForm()
	if form.validate_on_submit():
		user_name = request.form.get('username', None)
		password = request.form.get('password', None)
		remember_me = request.form.get('remember_me', False)
		user = User(user_name, password)
		if user.verify_password(password):
			login_user(user)
			return redirect(request.args.get('next') or url_for('main'))
	return render_template('login.html', title="Sign In", form=form)
开发者ID:linkagehzy,项目名称:code,代码行数:13,代码来源:runlogin.py

示例5: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
def login():
    phone_number = request.form['phone_number']
    password = request.form['password']

    if not User.verify_password(phone_number, password):
        flash('错误的邮箱或密码','danger')
    else:
        user = User.find_by_phone_number(phone_number)
        session['user_id'] = user[0]
        flash('成功登陆', 'success')
    return redirect(url_for('index'))
开发者ID:BlackieXS,项目名称:helping_system,代码行数:13,代码来源:views.py

示例6: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
def login():
    email = request.form['email']
    password = request.form['password']

    if not User.verify_password(email, password):
        flash('错误的邮箱或密码','danger')
    else:
        user = User.find_by_email(email)
        session['user_id'] = user['id']
        flash('成功登陆', 'success')
    return redirect(url_for('index'))
开发者ID:zhengqm,项目名称:neo4j-weibo,代码行数:13,代码来源:controllers.py

示例7: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
def login():
    if request.method == "POST":
        username = request.form["username"]
        password = request.form["password"]

        user = User(username)

        if not user.verify_password(password):
            flash("Invalid login.")
        else:
            flash("Successfully logged in.")
            session["username"] = user.username
            return redirect(url_for("index"))

    return render_template("login.html")
开发者ID:nicolewhite,项目名称:nothing,代码行数:17,代码来源:views.py

示例8: login

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
def login():
    error = None
    if request.method == 'POST':
        username = request.form['username']
        password = request.form['password']

        user = User(username)

        if not user.verify_password(password):
            error = 'Invalid login.'
        else:
            session['username'] = user.username
            flash('Logged in.')
            return redirect(url_for('index'))

    return render_template('login.html', error=error)
开发者ID:mekza,项目名称:neo4j-flask,代码行数:18,代码来源:views.py

示例9: test_password_verification

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
 def test_password_verification(self):
     u = User(password='cat')
     self.assertTrue(u.verify_password('cat'))
     self.assertFalse(u.verify_password('dog'))
开发者ID:Onebrownsound,项目名称:Microblogging_App,代码行数:6,代码来源:tests.py

示例10: users

# 需要导入模块: from models import User [as 别名]
# 或者: from models.User import verify_password [as 别名]
def users():
    if request.method=='POST':
        try:
            credentials=request.json
        except:
            return jsonify({'message':"no json"}), 400

        username=credentials.get('username')
        password=credentials.get('password')
        picture=credentials.get('picture')
        if not(username or password):
            return jsonify({'message':'no username or password provided'}), 400

        if session.query(User).filter_by(email=username).first() is not None:
            print "existing user"
            user = session.query(User).filter_by(email=username).first()
            return jsonify({'message':'user already exists'}), 200


        newuser=User(email=username,password_hash=password,picture=picture)
        newuser.hash_password(password)
        session.add(newuser)
        session.commit()
        return jsonify({'message':'User Created', 'User' : username}), 200
    if request.method=='GET':
        if not verify_password(1,2): return jsonify({'message':g.tok}), 404
        users=session.query(User).all()
        return jsonify(user = [i.serialize for i in users])
        #return jsonify(user = [i.serialize['email'] for i in users])
    if request.method=='PUT':
        if not verify_password(1,2): return jsonify({'message':g.tok}), 404

        try:
            credentials=request.json
        except:
            return jsonify({'message':"no json"}), 400

        username=credentials.get('username')
        password=credentials.get('password')
        picture=credentials.get('picture')
        if session.query(User).filter_by(email=username).first() is not None:

            newuser=session.query(User).filter_by(email=username).first()

            if newuser.id!=g.id:return jsonify({'message':"Token from another user"}), 400
            if newuser.email==username:
                asd=unicode(newuser.ext_hash(password))
                dsa=newuser.password_hash
                if newuser.verify_password(password):
                        if newuser.picture==picture:
                            return jsonify({'message':"Aborting, no change detected"}), 400
            newuser.email=username
            newuser.picture=picture
            pluto = newuser.hash_password(password)
            session.commit()
            return jsonify({'message':"User updated"}), 200
        else:
            return jsonify({'message':"User not existing"}), 400
    if request.method=='DELETE':
        if not verify_password(1,2): return jsonify({'message':g.tok}), 404
        newuser=session.query(User).filter_by(email=g.user.email).first()
        if newuser.id!=g.id:return jsonify({'message':"Token from another user"}), 400
        session.delete(newuser)
        session.commit()
        return jsonify({'message':"User deleted"}), 200
开发者ID:venturozzaccio,项目名称:Api_project,代码行数:67,代码来源:main.py


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