本文整理汇总了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)
示例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')
示例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))
示例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)
示例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'))
示例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'))
示例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")
示例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)
示例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'))
示例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