本文整理汇总了Python中user.User.new_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.new_user方法的具体用法?Python User.new_user怎么用?Python User.new_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.new_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import new_user [as 别名]
def new_user(self, email, display_name, password):
"""
Register new user
:param str email: User email
:param str display_name: User name
:param str password: User password in plain text
:returns: None
:raise: UserAlreadyExists
"""
User.new_user(email, password, display_name)
return {}
示例2: process_signup
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import new_user [as 别名]
def process_signup():
email, password, name, department = [request.form[attr] for attr in ['email', 'password', 'name', 'department']]
email = email.lower()
user = User.new_user(email, password, name, department)
try:
user.save()
except mongoengine.ValidationError as e:
failed_data = dict(email=email, name=name, department=department)
return render_template('signup.html', departments=DEPARTMENTS, error=e.message, **failed_data)
session['logged_in'] = user.email
return redirect('/')
示例3: process_login
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import new_user [as 别名]
def process_login():
email, password = request.form['email'].lower(), request.form['password']
user = User.objects(email=email).first()
if user is None or not user.valid_password(password):
return render_template('login.html', error="Wrong password or username.", email=email)
else:
session['logged_in'] = user.email
inject_user()
load_user()
return redirect('/')
@app.route('/api/etude/<etude_id>/notify', methods=['POST'])
def notify_etude(etude_id):
# TODO : implement sending a mail
etude = Etude.objects.get(number=etude_id)
g.user.etudes.append(etude)
g.user.save()
app.logger.info('Received notification by user "{}" for etude: \n{}'.format(g.user.name, etude))
return jsonify(ok=True)
if __name__ == "__main__":
# Creating dummy user
User.drop_collection()
dummy_user = User.new_user(email='[email protected]', password='123456', name='Richard Martin', department='IF')
dummy_user.save()
app.run(host='0.0.0.0', debug=True)
示例4: test_new_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import new_user [as 别名]
def test_new_user(self):
User.new_user("[email protected]", "password", "Cool name")
with self.assertRaises(errors.UserAlreadyExists) as r:
User.new_user("[email protected]", "password", "Cool name")