本文整理汇总了Python中app.users.models.User.accounts['internal']方法的典型用法代码示例。如果您正苦于以下问题:Python User.accounts['internal']方法的具体用法?Python User.accounts['internal']怎么用?Python User.accounts['internal']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.users.models.User
的用法示例。
在下文中一共展示了User.accounts['internal']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register
# 需要导入模块: from app.users.models import User [as 别名]
# 或者: from app.users.models.User import accounts['internal'] [as 别名]
def register():
email = request.form['email']
username = request.form['username']
password = request.form['password'].encode('utf8')
salt = generate_random_salt()
password_hash = generate_password_hash(password, salt)
# Check if email already exist in database
# if account does not exist create account in database
if User.objects(email=email).first() == None:
user = User(email=email)
user.accounts['internal'] = {"username":username, "password_hash":password_hash, \
"salt":salt}
user.save()
ret = json_util.dumps({"message":"account created", "status":"success"})
resp = Response(response=ret,
status=201,
mimetype="application/json")
return resp
else:
ret = json_util.dumps({"message":"Email already exist in database"})
resp = Response(response=ret,
status=200,
mimetype="application/json")
return resp