Example #1
0
def edit_account(user):
    target = models.User.get(models.User.username == user)

    form = forms.EditUserForm()

    if target.username == current_user.username:
        if form.validate_on_submit():
            try:
                target.update(
                    password=models.generate_password_hash(form.password.data)
                ).execute()

                flash('Password changed.', 'success')
                return redirect(url_for('index'))

            except TypeError:
                flash('Encountered error while editing.', 'warning')

    elif current_user.is_admin:
        if form.validate_on_submit():
            try:
                target.password=models.generate_password_hash(form.password.data)
                target.save()

                flash('Password changed for user {}.'.format(target.username), 'success')
                return redirect(url_for('index'))

            except TypeError:
                flash('Encountered error while editing {}.'.format(target.username), 'warning')

    return render_template('edit_user.html', form=form, user=target, LANGUAGES=languages.LANGUAGES)
Example #2
0
def accountinfo():
	if 'email' not in session:
		return redirect(url_for('signin'))

	form = PasswordForm()
	if request.method == 'POST':
		if form.validate() == False:
			return "validate"
		else:			
			deptotal = 'update * from `users` set `password` = '+str(generate_password_hash(form.psd1.data))+'where `actno` ='+str(session['uid']+' password='******'accountinfo.html', form=form)

	elif request.method == 'GET':
		return render_template('accountinfo.html', fname=session['fname'], lname=session['lname'], TotalDeposit=dpo.totaldeposit(), ShowDep=dpo.deposithistory(), TotalWithdrawal=dpo.withdraw(), AccountBalance=dpo.balance(),  form=form)