Python werkzeug 模块,generate_password_hash() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用werkzeug.generate_password_hash()

项目:ASE-Fall2016    作者:Dai0526    | 项目源码 | 文件源码
def register():
    """Registers the user."""
    if g.user:
        return redirect(url_for('home.timeline'))
    error = None
    if request.method == 'POST':
        if not request.form['username']:
            error = 'You have to enter a username'
        elif not request.form['email'] or \
                '@' not in request.form['email']:
            error = 'You have to enter a valid email address'
        elif not request.form['password']:
            error = 'You have to enter a password'
        elif request.form['password'] != request.form['password2']:
            error = 'The two passwords do not match'
        elif db.session.query(User).filter_by(username=request.form['username']).first() is not None:
            error = 'The username is already taken'
        else:
            user = User(request.form['username'], request.form['email'], generate_password_hash(request.form['password']))
            db.session.add(user)
            db.session.commit()
            flash('You were successfully registered and can login now')
            return redirect(url_for('users.login'))
    return render_template('register.html', error=error)
项目:ASE-Fall2016    作者:Dai0526    | 项目源码 | 文件源码
def register():
    """Registers the user."""
    if g.user:
        return redirect(url_for('home.timeline'))
    error = None
    if request.method == 'POST':
        if not request.form['username']:
            error = 'You have to enter a username'
        elif not request.form['email'] or \
                '@' not in request.form['email']:
            error = 'You have to enter a valid email address'
        elif not request.form['password']:
            error = 'You have to enter a password'
        elif request.form['password'] != request.form['password2']:
            error = 'The two passwords do not match'
        elif db.session.query(User).filter_by(username=request.form['username']).first() is not None:
            error = 'The username is already taken'
        else:
            user = User(request.form['username'], request.form['email'], generate_password_hash(request.form['password']))
            db.session.add(user)
            db.session.commit()
            flash('You were successfully registered and can login now')
            return redirect(url_for('users.login'))
    return render_template('register.html', error=error)
项目:Cloudroid    作者:cyberdb    | 项目源码 | 文件源码
def set_password(self, password):
        self.passwdhash = generate_password_hash(password)
项目:FRG-Crowdsourcing    作者:97amarnathk    | 项目源码 | 文件源码
def generate_password_hash(self, password):
        return generate_password_hash(password)
项目:Adventure-Insecure    作者:colinnewell    | 项目源码 | 文件源码
def create_user(attempt, form):
    u = User(form.name.data, attempt.email, generate_password_hash(form.password.data))
    db.session.add(u)
    db.session.delete(attempt)
    db.session.commit()
项目:pornote    作者:haltode    | 项目源码 | 文件源码
def set_password(self, password):
        self.password = generate_password_hash(password)
项目:flask    作者:bobohope    | 项目源码 | 文件源码
def set_password(self, password):
    self.pwdhash = generate_password_hash(password)