本文整理汇总了Python中rfk.database.base.User.make_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.make_password方法的具体用法?Python User.make_password怎么用?Python User.make_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rfk.database.base.User
的用法示例。
在下文中一共展示了User.make_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: settings
# 需要导入模块: from rfk.database.base import User [as 别名]
# 或者: from rfk.database.base.User import make_password [as 别名]
def settings():
form = SettingsForm(request.form,
username=current_user.username,
email=current_user.mail,
show_def_name=current_user.get_setting(code='show_def_name'),
show_def_desc=current_user.get_setting(code='show_def_desc'),
show_def_tags=current_user.get_setting(code='show_def_tags'),
show_def_logo=current_user.get_setting(code='show_def_logo'),
use_icy=current_user.get_setting(code='use_icy'))
if request.method == "POST" and form.validate():
if current_user.check_password(password=form.old_password.data):
if form.new_password.data:
current_user.password = User.make_password(form.new_password.data)
current_user.mail = form.email.data
current_user.set_setting(code='show_def_name', value=form.show_def_name.data)
current_user.set_setting(code='show_def_desc', value=form.show_def_desc.data)
current_user.set_setting(code='show_def_tags', value=form.show_def_tags.data)
current_user.set_setting(code='show_def_logo', value=form.show_def_logo.data)
current_user.set_setting(code='use_icy', value=form.use_icy.data)
rfk.database.session.commit()
flash(gettext('Settings successfully updated.'), 'success')
return redirect(url_for('settings'))
else:
form.old_password.errors.append(gettext('Wrong password.'))
return render_template('settings.html', form=form, TITLE='Settings',
imgur={'client': rfk.CONFIG.get('site', 'imgur-client')})
示例2: finish
# 需要导入模块: from rfk.database.base import User [as 别名]
# 或者: from rfk.database.base.User import make_password [as 别名]
def finish():
ret = {'success': False}
try:
if not User.check_username(request.form['username']):
ret['username'] = 'invalid'
elif len(request.form['password']) == 0:
ret['password'] = 'invalid'
elif len(request.form['stream_password']) == 0:
ret['stream_password'] = 'invalid'
elif User.get_user(username=request.form['username']) == None:
ret['success'] = True
user = User(request.form['username'],
User.make_password(request.form['password']),
User.make_password(request.form['stream_password']))
session.add(user)
session.commit()
else:
ret['username'] = 'taken'
except KeyError:
pass
response = jsonify(ret)
response.status_code = 200
return response