How to use the ramp-frontend.ramp_frontend.forms.PasswordForm function in ramp-frontend

To help you get started, we’ve selected a few ramp-frontend examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paris-saclay-cds / ramp-board / ramp-frontend / ramp_frontend / views / auth.py View on Github external
def reset_with_token(token):
    """Reset password by passing a token (email).

    Parameters
    ----------
    token : str
        The token associated with an email address.
    """
    try:
        email = ts.loads(token, max_age=86400)
    except Exception as e:
        logger.error(str(e))
        abort(404)

    form = PasswordForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=email).one_or_none()
        if user is None:
            logger.error('The error was deleted before resetting his/her '
                         'password')
            abort(404)
        (User.query.filter_by(email=email)
                   .update({
                       "hashed_password":
                       hash_password(form.password.data).decode()}))
        db.session.commit()
        return redirect(url_for('auth.login'))

    return render_template('reset_with_token.html', form=form, token=token)