本文整理汇总了Python中models.Account.hash_password方法的典型用法代码示例。如果您正苦于以下问题:Python Account.hash_password方法的具体用法?Python Account.hash_password怎么用?Python Account.hash_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Account
的用法示例。
在下文中一共展示了Account.hash_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signup
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import hash_password [as 别名]
def signup(username, password, email, facebook_id):
user = Account(username=username
,signup_date=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
,email=email, facebook_id=facebook_id)
user.hash_password(password)
db.session.add(user)
db.session.commit()
send_mail('testing_android', [user.email], {})
return "Adding successful"
示例2: new_user
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import hash_password [as 别名]
def new_user():
username = request.json.get('username')
password = request.json.get('password')
callback = request.json.get('callback')
if username is None or password is None:
abort(400) # missing arguments
if Account.query.filter_by(username=username).first() is not None:
abort(400) # existing user
user = Account(username=username)
user.hash_password(password)
user.callback = callback
db.session.add(user)
db.session.commit()
return jsonify({'username': user.username}), 201, \
{'Location': url_for('get_user', id=user.id, _external=True)}