예제 #1
0
def user(username):
    form = ChangePasswordForm()
    if form.validate_on_submit():
        current_user.set_password(form.new_pass.data)
        db.session.commit()
        flash('Password changed.')
    form2 = ChangeEmailForm()
    if form2.validate_on_submit():
        current_user.email = form2.new_email.data
        db.session.commit()
        flash('Email updated.')
    user = User.query.filter_by(username=username).first_or_404()
    subs = (Paper.query.filter_by(subber=user).order_by(
        Paper.timestamp.desc()))[:10]
    vols = (Paper.query.filter_by(volunteer=user).order_by(
        Paper.timestamp.desc()))[:10]
    ups = (Upload.query.filter_by(uploader=user).order_by(
        Upload.timestamp.desc()))[:10]
    return render_template('main/user.html',
                           user=user,
                           form=form,
                           subs=subs,
                           showsub=False,
                           form2=form2,
                           ups=ups,
                           vols=vols,
                           current_user=current_user)
예제 #2
0
파일: routes.py 프로젝트: Jerk-art/DFY
def change_password(token):
    try:
        user = User.get_user_by_confirmation_token(token)
        form = ChangePasswordForm()
        if user:
            if current_user.is_authenticated:
                if user != current_user:
                    abort(400)
            if request.method == 'GET':
                return render_template('auth/change_password.html', form=form)
            else:
                if form.validate_on_submit():
                    user.set_password_hash(form.password.data)
                    db.session.add(user)
                    db.session.commit()
                    flash('Your password successfully changed!')
                    if current_user.is_authenticated:
                        return render_template('auth/info.html')
                    else:
                        return redirect(url_for('auth.sign_in'))
                else:
                    return render_template('auth/change_password.html',
                                           form=form)
        else:
            abort(404)
    except VerificationError:
        abort(404)
def change_password():
    # If sign in form is submitted
    form = ChangePasswordForm(request.form)
    # Verify the sign in form
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and PasswordLib().check_password(form.password.data,
                                                 user.password):
            password_history_count = ConfigService().get_password('history')
            passwords = History.query.filter_by(
                userid=user.id).limit(password_history_count)
            for password in passwords:
                if PasswordLib().check_password(form.new_pass.data,
                                                password.password):
                    flash('Password found in near history', 'error')
                    return redirect(url_for('auth.change_password'))
            new_password_salted = PasswordLib().get_hashed_password(
                form.new_pass.data)
            user.password = new_password_salted
            password_history = History(userid=user.id,
                                       password=new_password_salted)
            db.session.add(password_history)
            db.session.commit()
            flash(f'Password changed for {user.name}!', 'info')
            return redirect(url_for('index.home'))
        flash('Wrong email or password', 'error')
    return render_template("auth/changepass.html", form=form)
예제 #4
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        current_user.password = form.new_password.data
        db.session.add(current_user)
        flash('change password successfully!')
        return redirect(url_for('main.index'))
    return render_template('auth/change_password.html', form=form)
예제 #5
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        current_user.set_password(form.password.data)
        db.session.commit()
        flash(_('Passwort geändert'))
        return redirect(url_for('main.index'))
    return render_template('auth/change_password.html', form=form)
예제 #6
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        current_user.password = form.new_password.data
        db.session.commit()
        flash('Password successfully changed.', 'success')
        return redirect(url_for('auth.change_password'))
    return render_template('auth/change_password.html', form=form)
예제 #7
0
def change_password():
    user = User.query.get(current_user.id)
    form = ChangePasswordForm()
    if form.validate_on_submit():
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        return redirect('/profile')
    return render_template('auth/change_password.html', form=form)
예제 #8
0
def change_password() -> str:
    form = ChangePasswordForm()
    if form.validate_on_submit():
        user = User.query.filter_by(username=current_user.username).first()
        if user:
            user.set_password(form.password.data)
            db.session.commit()
            flash("You change your password successfully.")
            return redirect(url_for("main.user", username=current_user.username))
    return render_template("auth/form.html", title="Change Password", form=form)
예제 #9
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        current_user.password = form.new_password.data
        db.session.add(current_user)
        db.session.commit()

        flash('Your password has been updated.')
        return redirect(url_for('main.index'))
    return render_template('auth/change_password.html', form=form)
예제 #10
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        current_user.set_password(form.password.data)
        db.session.commit()
        flash('Your password has been changed.')
        return redirect(url_for('main.edit_profile'))
    return render_template('auth/change_password.html',
                           title='Change Your Password',
                           form=form)
예제 #11
0
파일: views.py 프로젝트: paralleasty/Ablog
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.validate_password(form.old_password.data):
            current_user.password = form.password.data
            db.session.add(current_user)
            db.commit()
            return redirect(url_for('main.index'))
        return redirect(url_for('auth.changepwd'))
    return render_template('auth/changepwd.html', form=form)
예제 #12
0
def changepassword():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            current_user.password = form.new_password.data
            flash(u'密码修改成功,您可退出登入并使用新密码登入系统')
            return redirect(url_for('auth.changepassword'))
        flash(u'提交信息无效,请重新输入')
    return render_template('auth/password/changepassword.html',
                           app_name='Flask-BMS',
                           form=form)
예제 #13
0
파일: routes.py 프로젝트: cdcf/t-e-manager
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.check_password(form.old_password.data):
            current_user.set_password(form.password.data)
            db.session.commit()
            flash('Your password has been updated.', 'success')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid password.', 'danger')
    return render_template("auth/change_password.html", form=form)
예제 #14
0
파일: views.py 프로젝트: Ezi4Zy/ezi_web
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.password.data
            db.session.add(current_user)
            flash('Your password has been update.')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid Password')
    return render_template('auth/change_password.html', form=form)
예제 #15
0
파일: views.py 프로젝트: weixiaohhh/myzhihu
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.password.data
            db.session.add(current_user)
            flash('Your password has been updated.')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid password.')
    return render_template("auth/change_password.html", form=form)
예제 #16
0
def change_password():
	form = ChangePasswordForm()
	if form.validate_on_submit():
		if not current_user.check_password(form.password.data):
			flash(_('Wrong Password'))
			return redirect(url_for('auth.change_password'))
		current_user.set_password(form.password_new.data)
		db.session.commit()
		flash(_('Your password has been changed'))
		return redirect(url_for('auth.user', username=current_user.username))
	return render_template('auth/change_password.html', form=form)
예제 #17
0
def settings():
    form = ChangePasswordForm()
    if not form.validate_on_submit():
        return render_template("auth/settings.html.j2", form=form)
    if not current_user.verify_password(form.old_password.data):
        flash("Incorrect current password")
        return render_template("auth/settings.html.j2", form=form)
    current_user.password = form.new_password.data
    db.session.add(current_user)
    db.session.commit()
    flash("Your password has been updated")
    return redirect(url_for("auth.settings"))
예제 #18
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.new_password.data
            db.session.add(current_user)
            db.session.commit()
            flash(_('Your password has been updated'), 'success')
            return redirect(url_for('main.index'))
        else:
            flash(_('Invalid password'), 'warning')
    return render_template('auth/change_password.html', form=form)
예제 #19
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.password.data
            db.session.add(current_user)
            db.session.commit()
            flash('您的密码已经修改')
            return redirect(url_for('main.index'))
        else:
            flash('当前密码错误')
    return render_template('auth/change_password.html', form=form)
예제 #20
0
파일: routes.py 프로젝트: incidunt/51-read
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.check_password(form.old_password.data):
            current_user.set_password(form.password.data)
            db.session.add(current_user)
            db.session.commit()
            flash(Markup('Your password has been updated.'), "info")
            return redirect(url_for('main.index'))
        else:
            flash(Markup('Invalid password.'), "warning")
    return render_template("auth/change_password.html", title='Change password', form=form)
예제 #21
0
def change_password():
    form = ChangePasswordForm(request.form)
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.password.data
            db.session.add(current_user)
            db.session.commit()
            flash('密码更新成功')
            return redirect(url_for('main.index'))
        else:
            flash('无效的密码')
    return render_template("auth/change_email.html", title="密码管理", form=form)
예제 #22
0
def change_password():
  form = ChangePasswordForm()
  if form.validate_on_submit():
    if current_user.check_password(form.old_password.data):
      current_user.set_password(form.new_password.data)
      db.session.commit()
      flash('Your password has been changed.')
      return redirect(url_for('main.user', username=current_user.username))
    else:
      flash('Current password incorrect.')
      return redirect(url_for('auth.change_password'))
  return render_template('auth/change_password.html', form=form)
예제 #23
0
파일: routes.py 프로젝트: JChatelin/HiGuys
def reset_password(token):
    if current_user.is_authenticated:
        return redirect(url_for('core.index'))
    user = User.verify_reset_password_token(token)
    if user is None:
        return redirect(url_for('auth.login'))
    form = ChangePasswordForm()
    if form.validate_on_submit():
        user.set_password(form.password.data)
        db.session.commit()
        flash('Your password has been reset.')
        return redirect(url_for('auth.login'))
    return render_template('auth/reset_password.html', form=form)
예제 #24
0
def change_password():
    """Change an existing user's password."""
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.new_password.data
            db.session.add(current_user)
            db.session.commit()
            flash('Your password has been updated.', 'form-success')
            return redirect(url_for('main.index'))
        else:
            flash('Original password is invalid.', 'form-error')
    return render_template('account/manage.html', form=form)
예제 #25
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)
예제 #26
0
def change_password():
    if request.method == 'GET':
        manage_prev_page()
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.check_password(form.oldpassword.data) and \
        form.newpassword.data == form.confirmation.data:
            current_user.set_password(form.newpassword.data)
            db.session.commit()
            flash('Your password has been updated')
            return redirect(session['prev_page'])
        else:
            flash('Please check your credentials')
    return render_template("auth/change_password.html", form=form)
예제 #27
0
def change_password():
    """Change password page"""
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if not current_user.check_password(form.old_password.data):
            flash(_('Wrong password'))
            return redirect(url_for('auth.change_password'))
        current_user.set_password(form.new_password.data)
        flash(_('Password changed'))
        db.session.commit()
        return redirect(url_for('auth.change_password'))
    return render_template('default-form.html',
                           title=_('Change Password'),
                           form=form)
예제 #28
0
파일: routes.py 프로젝트: Clue88/metis2
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.check_password(form.old_password.data):
            current_user.set_password(form.password.data)
            db.session.commit()
            flash("Your changes have been saved.")
            return redirect(url_for("main.profile"))
        else:
            flash("Incorrect password.")
            return redirect(url_for("auth.change_password"))
    return render_template("auth/change_password.html",
                           title="Change Password",
                           form=form)
예제 #29
0
def change_password():
    # if current_user != User.get_by_username(username):

    form = ChangePasswordForm()
    if form.validate_on_submit():
        user = User.get_by_username(current_user.username)
        if user.check_password(form.old_password.data):
            user.password = form.new_password.data
            db.session.commit()
            flash(f"Password successfully changed.", 'success')
            return redirect(url_for('user.user', username=current_user.username))
        else:
            flash(f"Current password is incorrect.", 'danger')
    return render_template('change_password.html', form=form)
예제 #30
0
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.password.data
            current_user.save()
            flash('Your password has been updated.', 'success')
            return redirect(url_for('dashboard.dashboard'))
        else:
            flash('Invalid password.', 'warning')
    return render_template(
        "auth/change_password.html",
        title="Change your password",
        form=form,
    )
예제 #31
0
def reset_password() -> str:
    if current_user.is_authenticated:
        return redirect(url_for("main.index"))
    token = request.args.get("token")
    _id = verify_token(token).get("id", None)
    user = User.get_user(_id)
    if not user:
        return redirect(url_for("main.index"))
    form = ChangePasswordForm()
    if form.validate_on_submit():
        user.set_password(form.password.data)
        db.session.commit()
        flash("Your password has been reset.")
        return redirect(url_for("auth.login"))
    return render_template("auth/form.html", title="Change Password", form=form)