本文整理汇总了Python中model.User.create_new_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.create_new_user方法的具体用法?Python User.create_new_user怎么用?Python User.create_new_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.create_new_user方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sign_up
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create_new_user [as 别名]
def sign_up():
user_name = request.form.get('name')
user_email = request.form.get('email')
user_password = request.form.get('password')
new_user = User.create_new_user(user_name, user_email, user_password)
session['logged_in_user'] = new_user.user_id
return redirect('/')
示例2: confirm_new_account
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create_new_user [as 别名]
def confirm_new_account():
"""Confirm new account"""
user_email = request.form.get("email")
user_password = request.form.get("password1")
user_phone = request.form.get("phone")
confirmed_user = User.get_user_by_email(user_email)
if not confirmed_user:
hash = sha256_crypt.encrypt(user_password)
User.create_new_user(user_email, hash, user_phone)
flash("You successfully created an account! Please log in to get started.", "create_account")
else:
flash("You already have an account. Please sign in.", "account_already")
return redirect("/")
示例3: register_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import create_new_user [as 别名]
def register_user():
"""Registers User"""
register_email = request.form["email_input"]
register_password = request.form["password_input"]
register_username = request.form["username_input"]
if User.query.filter(User.email == register_email).first():
flash("A person has already registered with the email")
return redirect("/")
elif User.query.filter(User.username == register_username).first():
flash("A person has already taken that username")
return redirect("/")
else:
if register_email and register_password and register_username:
User.create_new_user(email=register_email,
password=register_password,
username=register_username)
flash("Thanks for creating an account with Gutenberg Translate! Please sign in")
return redirect("/")
else:
flash("Please fill out all fields")
return redirect("/")