本文整理汇总了Python中User.email方法的典型用法代码示例。如果您正苦于以下问题:Python User.email方法的具体用法?Python User.email怎么用?Python User.email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类User
的用法示例。
在下文中一共展示了User.email方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: admin_users_add
# 需要导入模块: import User [as 别名]
# 或者: from User import email [as 别名]
def admin_users_add():
user = User()
user.id = ''
user.firstname = ''
user.lastname = ''
user.email = ''
return render_template('user.html', user=user)
示例2: login
# 需要导入模块: import User [as 别名]
# 或者: from User import email [as 别名]
def login(provider_name):
response = make_response()
result = current_app.authomatic.login(
WerkzeugAdapter(request, response), provider_name
)
if result:
if result.user:
first_login = False
result.user.update()
user = User.objects(provider=provider_name, user_id=result.user.id).first()
if user is None:
user = User(
username=result.user.username,
email=result.user.email,
name=result.user.name,
user_id=result.user.id,
provider=provider_name
)
user.save()
first_login = True
else:
user.name = result.user.name
user.email = result.user.email
user.save()
session['user_id'] = user.user_id
return redirect_next()
flash_error('Authentication failed')
return redirect(url_for('auth.login_page', next=request.path))
return response
示例3: new_user
# 需要导入模块: import User [as 别名]
# 或者: from User import email [as 别名]
def new_user(request):
"""Add a new user to the system manually."""
rdict = request.params
u = User()
u.username = unicode(rdict.get('username'))
u.email = unicode(rdict.get('email'))
passwd = get_random_word(8)
u.password = passwd
u.activated = True
u.is_admin = False
u.api_key = User.gen_api_key()
try:
DBSession.add(u)
DBSession.flush()
# We need to return the password since the admin added the user
# manually. This is only time we should have/give the original
# password.
ret = dict(u)
ret['random_pass'] = passwd
return _api_response(request, ret)
except IntegrityError, exc:
# We might try to add a user that already exists.
LOG.error(exc)
request.response.status_int = 400
return _api_response(request, {
'error': 'Bad Request: User exists.',
})
示例4: register
# 需要导入模块: import User [as 别名]
# 或者: from User import email [as 别名]
def register():
def check():
email_exists = User.query.filter(db.func.lower(User.email) == form.email.data.lower()).first()
if email_exists:
flash('Пользователь с такой электронной почтой уже зарегистрирован.', 'danger')
return False
return True
user = User()
form = forms.RegisterForm(obj=user)
if form.validate_on_submit() and check():
if form.password.data != form.password2.data:
flash('Введённые пароли не совпадают.')
else:
user.email = form.email.data
user.name = form.name.data
user.password_hash = User.hash_password(form.password.data)
user.roles = 0
db.session.add(user)
db.session.commit()
return render_template('users/after_register.html', email=user.email)
flash_errors(form)
return render_template('users/register.html', form=form)