コード例 #1
0
def test_form_labels(app):
    app.config["BABEL_DEFAULT_LOCALE"] = "fr_FR"
    app.security = Security()
    app.security.init_app(app)
    assert check_xlation(
        app, "fr_FR"), "You must run python setup.py compile_catalog"

    with app.test_request_context():
        rform = RegisterForm()
        assert str(rform.password.label.text) == "Mot de passe"
        assert str(
            rform.password_confirm.label.text) == "Confirmer le mot de passe"
        assert str(rform.email.label.text) == "Adresse email"
        assert str(rform.submit.label.text) == "Inscription"

        form = LoginForm()
        assert str(form.password.label.text) == "Mot de passe"
        assert str(form.remember.label.text) == "Se souvenir de moi"
        assert str(form.email.label.text) == "Adresse email"
        assert str(form.submit.label.text) == "Connexion"

        form = ChangePasswordForm()
        assert str(form.password.label.text) == "Mot de passe"
        assert str(form.new_password.label.text) == "Nouveau mot de passe"
        assert str(form.new_password_confirm.label.text
                   ) == "Confirmer le mot de passe"
        assert str(form.submit.label.text) == "Changer le mot de passe"
コード例 #2
0
def settings():
    form = UserDataForm(request.form, obj=current_user)
    change_password_form = ChangePasswordForm()

    if form.validate_on_submit():
        form.populate_obj(current_user)
        db.session.add(current_user)
        db.session.commit()
        current_app.logger.info('%s updated his / her user data' %
                                current_user.email)
        flash(_('User data saved'), 'success')
    elif change_password_form.validate_on_submit():
        flash(_('Password changed'), 'success')
        return render_template('/settings.html')
    return render_template('my-settings.html',
                           form=form,
                           change_password_form=change_password_form)
コード例 #3
0
def home():
    if current_user.temp_pass == True:
        db.session.query(User).filter_by(id=current_user.id).update(
            {'temp_pass': (False)})
        db.session.commit()
        return render_template('security/change_password.html',
                               change_password_form=ChangePasswordForm())
    else:
        return render_template('index.html')
コード例 #4
0
def profile():
    form = GenerateApiKeyForm()
    if form.validate_on_submit():
        current_user.api_key = generate_api_key()
        db.session.commit()
        return redirect(url_for('frontend.profile'), code=303)
    form.api_key.data = current_user.api_key
    return render_template('frontend/profile.html', change_password_form=ChangePasswordForm(),
                           generate_api_key_form=form)
コード例 #5
0
ファイル: main.py プロジェクト: Laiot/Filum-Ariadnae
def change():
    changed = 'false'
    user = current_user._get_current_object()
    change_form = ChangePasswordForm()
    if request.method == 'GET':
        return render_template('change.html',
                               user=user,
                               change_form=change_form,
                               changed=changed)
    else:
        if change_form.validate_on_submit() or change_form.validate():
            user.password = hash_password(change_form.new_password.data)
            user_datastore.put(user)
            db_session.commit()
            changed = 'true'
        return render_template('change.html',
                               user=user,
                               change_form=change_form,
                               changed=changed)
コード例 #6
0
ファイル: users.py プロジェクト: renefs/flask-skeleton
def change_password():
    change_password_form = ChangePasswordForm()
    change_social_password_form = ChangeSocialPasswordForm(prefix="social")

    if change_password_form.validate_on_submit():
        current_user.password = encrypt_password(change_password_form.new_password.data)
        current_user.has_autogenerated_password = False
        db.session.commit()
        flash("Password changed successfully", "success")
        return redirect(url_for('users.profile'))

    if change_social_password_form.validate_on_submit():
        current_user.password = encrypt_password(change_social_password_form.password.data)
        current_user.has_autogenerated_password = False
        db.session.commit()
        flash("Password changed successfully", "success")
        return redirect(url_for('users.profile'))

    return render_template('users/change_password.html', change_password_form=change_password_form,
                           change_social_password_form=change_social_password_form)
コード例 #7
0
ファイル: settings.py プロジェクト: tholen/crestify
def settings():
    user_details = User.query.get(current_user.id)
    bookmarks_per_page_form = PerPageForm(obj=user_details)
    import_bookmark_file_form = BookmarkImportForm()
    regenerate_api_key_form = RegenerateApiKeyForm()
    change_password_form = ChangePasswordForm()
    return render_template("manager/settings.html",
                           per_page=bookmarks_per_page_form,
                           import_form=import_bookmark_file_form,
                           regenerate_api_key_form=regenerate_api_key_form,
                           change_password_form=change_password_form,
                           user_api_key=user_details.api_key,
                           user_email=user_details.email)
コード例 #8
0
def change_password():
    if current_user.is_anonymous:
        message = "You must log in before changing your password."
        return render_template('message.html', message=message)

    if current_user.is_ldap:
        message = (
            'Your password can be changed only from the EIONET website ' +
            '(' + os.environ.get('EEA_PASSWORD_RESET') + ').')
        return render_template('message.html', message=message)

    form = ChangePasswordForm()

    if form.validate_on_submit():
        change_user_password(current_user, form.new_password.data)
        models.db.session.commit()
        msg = "Your password has been changed. Please log in again."
        flash(msg, 'success')
        return redirect(url_for(HOMEPAGE_VIEW_NAME))

    return render_template('auth/change_password.html', **{
        'form': form,
    })