Beispiel #1
0
def change_password():
    uid = current_user.get_id()
    pw_old = request.form['oldpwd']
    if not current_user.authenticate(pw_old):
        flask.flash("Ooops, old password is wrong!", "error")
        return flask.redirect(url_for(".info"))

    pw1 = request.form['password1']
    pw2 = request.form['password2']
    if pw1 != pw2:
        flask.flash("Oops, new passwords do not match!", "error")
        return flask.redirect(url_for(".info"))

    pwdmanager.change_password(uid, pw1)
    flask.flash("Your password has been changed.")
    return flask.redirect(url_for(".info"))
Beispiel #2
0
def change_password():
    uid = current_user.get_id()
    pw_old = request.form['oldpwd']
    if not current_user.authenticate(pw_old):
        flask.flash("Ooops, old password is wrong!", "error")
        return flask.redirect(url_for(".info"))

    pw1 = request.form['password1']
    pw2 = request.form['password2']
    if pw1 != pw2:
        flask.flash("Oops, new passwords do not match!", "error")
        return flask.redirect(url_for(".info"))

    pwdmanager.change_password(uid, pw1)
    flask.flash("Your password has been changed.")
    return flask.redirect(url_for(".info"))
Beispiel #3
0
def show_profile():
	form = forms.ChangePasswordForm()
	if request.method == 'GET':
		return render_template('profile.html', user=current_user, form=form)
	elif request.method == 'POST':
		if not form.validate(): 
			flash('All fields are required.','warning')
		else: 
			# get form data
			password = form.old_password.data
			# check that old password is correct
			if not current_user.authenticate(password): 
				flash('Incorrect old password.', 'warning')
			# check that new passwords match
			elif form.new_password.data != form.new_password_v.data:
				flash('New passwords must match.', 'warning')
			else:
				model.change_password(current_user.user_id, form.new_password.data)
				flash('Your password has been changed.', 'success')
			# add new password to db
		return render_template('profile.html', user=current_user, form=form)
Beispiel #4
0
def show_profile():
    form = forms.ChangePasswordForm()
    if request.method == 'GET':
        return render_template('profile.html', user=current_user, form=form)
    elif request.method == 'POST':
        if not form.validate():
            flash('All fields are required.', 'warning')
        else:
            # get form data
            password = form.old_password.data
            # check that old password is correct
            if not current_user.authenticate(password):
                flash('Incorrect old password.', 'warning')
            # check that new passwords match
            elif form.new_password.data != form.new_password_v.data:
                flash('New passwords must match.', 'warning')
            else:
                model.change_password(current_user.user_id,
                                      form.new_password.data)
                flash('Your password has been changed.', 'success')
            # add new password to db
        return render_template('profile.html', user=current_user, form=form)
Beispiel #5
0
def logout():
    current_user.authenticate(is_authentic=False)
    logout_user()
    flash('You are logged out.', 'info')
    return redirect(url_for('baseapp.home'))