本文整理汇总了Python中models.Player.password方法的典型用法代码示例。如果您正苦于以下问题:Python Player.password方法的具体用法?Python Player.password怎么用?Python Player.password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Player
的用法示例。
在下文中一共展示了Player.password方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import password [as 别名]
def register():
if request.method == "POST":
email = request.form['email']
username = request.form['username']
if len(session.query(Player).filter(Player.username == username).all()) < 1:
password = generate_password_hash(request.form['password'], method='pbkdf2:sha1', salt_length=8)
player = Player()
player.email = email
player.username = username
player.password = password
player.authenticated = True
session.add(player)
session.commit()
login_user(player)
flash('Account created and logged in.', 'success')
return redirect(url_for('game_page'))
else:
flash('That username is taken.', 'error')
return redirect(url_for('register'))
return render_template('register.html')