Пример #1
0
def changePassword():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.change_password(form.password.data)
            return redirect(url_for('auth.login'))
    return render_template('auth/changePassword.html', form=form)
Пример #2
0
def update_user_information_password():
    form = ForgetPasswordResetPasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.change_password(form.new_password.data)
            db.session.commit()
            flash('修改密码成功,请重新登录!')
            return redirect(url_for('auth.logout'))
        flash('密码错误!')
    return render_template('auth/resetPassword.html', form=form)
Пример #3
0
def change_password():
    form = ChangePasswordForm(request.form)

    if request.method == 'POST' and form.validate():
        if current_user.check_password(form.old_password.data):
            current_user.change_password(form.password1.data)
            flash('您的密码已重置,请使用新密码登录')
            return redirect(url_for('web.login'))
        flash('密码更改失败')
    return render_template('auth/change_password.html')
Пример #4
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            current_user.change_password(form.new_password.data)
            db.session.commit()
            flash('Password changed successfully', 'success')
            return redirect(url_for('main.home'))
        else:
            flash('Check your password and try again', 'danger')
    return render_template('auth/change_password.html',
                           user=current_user,
                           form=form)
def editpassword():
    form = EditPassword()
    if form.validate_on_submit():
        if User.check_password(current_user.password, form.old_password.data):
            current_user.change_password(form.password.data)
            flash('Your changes have been saved.')
            return redirect(
                request.args.get("next")
                or url_for('home', username=current_user.username))
        else:
            flash("Invalid password")
    #return user.__dict__
    return render_template('editpassword.html', form=form)
Пример #6
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.oldpassword.data):
            current_user.change_password(form.newpassword.data)
            db.session.add(current_user)
            db.session.commit()
            flash('Your password has been updated!', 'success')
            return redirect(url_for('main.index'))
        flash('Your password is incorrect.', 'danger')
    for field, errors in form.errors.items():
        for error in errors:
            flash(
                u"Error in the %s field - %s" %
                (getattr(form, field).label.text, error), 'danger')
    return render_template('auth/form.html', form=form, name='Change Password')
Пример #7
0
def reset_password():
    if current_user.is_authenticated:
        form = SimpleResetPwForm()
    else:
        form = ResetPasswordForm()
    if form.validate_on_submit():
        if current_user.is_authenticated:
            if current_user.change_password(form.password.data) is not None:
                flash("修改密码成功", category="info")
            else:
                flash("修改密码失败, 请联系管理员")
            logout_user()
            return redirect(url_for("main_view.login"))
        r = scrawl_score(form)
        if not isinstance(r, requests.Response):
            flash(r)
            return redirect(url_for("main_view.reset_password"))
        user = User.query.get(form.kaohao.data)
        user = user.change_password(form.password.data)
        if user is None:
            flash("查询密码更改失败,请联系管理员")
        else:
            flash("修改密码成功", category="info")
        logout_user()
        return redirect(url_for("main_view.login"))
    return render_template("form.html", form=form)
Пример #8
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        next_ = url_for('auth.login')
        if not current_user.change_password(form, record_log=False):
            next_ = url_for('auth.change_password')
        return redirect(next_)
    return render_template('auth/change_password.html', form=form)
def change_password():
    old_password = request.form['old_password']
    new_password = request.form['new_password']
    if current_user.change_password(old_password, new_password):
        flash('Password changed successfully', 'info')
        return redirect(url_for('authentication.login'))
    else:
        flash('Some error occured', 'error')
        return redirect(url_for('authentication.change_password'))
Пример #10
0
    def change_password(self):
        """Change password """
        try:
            self._assert_current_password()
            password = request.form.get("password", "").strip()
            password_confirm = request.form.get("password_confirm", "").strip()
            if password != password_confirm:
                raise exceptions.AuthError("Passwords don't match")
            current_user.change_password(password)
            flash_success(_("Your password updated successfully!"))
        except exceptions.AuthError as ex:
            flash_error(str(ex))
        except Exception as e:
            logging.exception(e)
            flash_error(_("Unable to update password"))

        redirect_url = request.form.get("redirect") or self.account_settings
        return redirect(redirect_url)
Пример #11
0
def change_password():
    if request.method == 'GET':
        return render_template('auth/change_password.html')
    form = ChangePasswordForm(request.form)
    print(form.old_password.data, form.new_password1.data,
          form.new_password2.data)
    if not form.validate():
        flash('请规范填写!')
        return redirect(url_for('web.change_password'))

    old_password = form.old_password.data
    if not current_user.check_password(old_password):
        flash('旧密码错误!')
        return redirect(url_for('web.change_password'))

    if form.new_password1.data == form.new_password2.data:
        current_user.change_password(form.new_password1.data)
        flash('重置密码成功!请您牢记!')

    return redirect(url_for('web.login'))
Пример #12
0
def change_password():
    """Frontend page to change the user's password"""
    form = ChangePasswordForm()

    if form.validate_on_submit():
        old = form.old.data
        new = form.new.data

        try:
            current_user.re_authenticate(old)
            current_user.change_password(old, new)
        except PasswordInvalid:
            flash(gettext("Altes Passwort war inkorrekt!"), "error")
        else:
            flash(gettext("Passwort wurde geändert"), "success")
            return redirect(url_for('.index'))
    elif form.is_submitted():
        flash_formerrors(form)

    return render_template("usersuite/change_password.html", form=form)
Пример #13
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.change_password(form.old_password.data,
                                        form.new_password.data):
            db.session.commit()
            flash('您的密码修改成功')
            return redirect(url_for('main.index'))
        else:
            flash('旧密码错误')
    return render_template('auth/change_password.html', form=form)
Пример #14
0
def change_password():
    """登录后修改自己账户密码"""
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.change_password(form.old_password.data,
                                        form.new_password.data):
            flash('您的密码已成功修改,请登录')
            logout_user()
            return redirect(url_for('auth.login'))
        flash('忘记现有密码?请重新输入')
        return redirect(url_for('auth.change_password'))
    return render_template('auth/change_password.html', form=form)
Пример #15
0
def security_center():
    email_form = ChangeEmailForm()
    password_form = ChangePasswordForm()
    if email_form.validate_on_submit():
        send_email(email_form.email.data, '【邮箱更改验证】', 'email/changeEmail', token=current_user.change_email_token(email_form.email.data), user=current_user)
        flash('系统已发送邮件到新邮箱,稍后请在邮件中完成相关操作!')
        return redirect(url_for('user.user_center', id=current_user.id))
    if password_form.validate_on_submit():
        if current_user.change_password(password_form.oldPassword.data, password_form.newPassword1.data):
            flash('密码更改成功, 请重新登录!')
            logout_user()
            return redirect(url_for('user.login'))
    return render_template('user/security_center.html', email_form=email_form, password_form=password_form)
Пример #16
0
def change_password():
    form = ChangePasswordForm()
    if request.method == 'POST' and form.validate_on_submit():
        current_password = form.current_password.data
        new_password = form.new_password.data
        confirm_password = form.confirm_password.data

        if Utils.check_password(current_user.password, current_password):
            if new_password == confirm_password:
                current_user.change_password(new_password)
                flash("Your password changed.")
                return redirect(url_for('users.home'))

            else:
                flash("The confirm password not matched.")
                return redirect(url_for('users.change_password'))

        else:
            flash("your current password is wrong.")
            return redirect(url_for('users.change_password'))

    return render_template('user/change_pw.html', form=form)
Пример #17
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.change_password(form.old_password.data,
                                        form.password.data):

            #current_user.verify_password(form.old_password.data):
            #current_user.change_password = form.password.data
            #db.session.add(current_user)
            flash('您的口令已经更新.')
            return redirect(url_for('main.index'))
        else:
            flash('口令错误.')
    return render_template("auth/change_password.html", form=form)
Пример #18
0
def change_password():
    form = Change_password()
    if form.validate_on_submit():
        old_password = form.old_password.data
        new_password = form.password.data
        result = current_user.change_password(old_password, new_password)
        if result:
            flash("You have changed your password", "good")
            return redirect(
                url_for("main.profile", user_id=current_user.user_id))
        else:
            flash("old email is not correct", "bad")
    return render_template("single_form.html",
                           form=form,
                           title="Change password")