本文整理汇总了Python中database.User.password方法的典型用法代码示例。如果您正苦于以下问题:Python User.password方法的具体用法?Python User.password怎么用?Python User.password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类database.User
的用法示例。
在下文中一共展示了User.password方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import password [as 别名]
def create_user(Session,username,password,public_key,creator):
s=Session
user=get_user(s,username)
if user is None:
if creator:
cid=creator.id
else:
cid=None
u=User(name=username,password=genpw(password),creator=cid,public_key=public_key)
s.add(u)
s.commit()
return True
else:
u=user
if not creator: return False
if u.id==creator.id or creator.name=='admin':
if not password is None:
if password=='':
u.password=''
else:
u.password=genpw(password)
if not public_key is None:
u.public_key=public_key
s.merge(u)
s.commit()
return True
return False
示例2: register_view
# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import password [as 别名]
def register_view(self):
form = RegistrationForm(request.form)
if helpers.validate_form_on_submit(form):
user = User()
form.populate_obj(user)
# we hash the users password to avoid saving it as plaintext in the db,
# remove to use plain text:
user.password = generate_password_hash(form.password.data)
db.session.add(user)
db.session.commit()
login.login_user(user)
return redirect(url_for('.index'))
link = '<p>Already have an account? <a href="' + url_for('.login_view') + '">Click here to log in.</a></p>'
self._template_args['form'] = form
self._template_args['link'] = link
return super(MyAdminIndexView, self).index()
示例3: register_view
# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import password [as 别名]
def register_view():
form = RegistrationForm(request.form)
if form.validate_on_submit():
user = User()
form.populate_obj(user)
user.salt = str(time.time())
hash_password = hashlib.sha512()
hash_password.update(user.salt + user.password)
user.password = hash_password.hexdigest()
db.session.add(user)
db.session.commit()
login.login_user(user)
flash('You were registered', 'info')
return redirect(url_for('show_challenges'))
return render_template('form.html', form=form)