def change_password(user): form = EnterForms.ChangePassword(request.form) if request.method == 'POST': if request.form['submit'] == 'Submit' and form.validate(): try: EnterpriseAPI.ChangePassword(user, request.form['currentpswd'], request.form['newpswd']) flash('Password changed successfully', category = 'success') return redirect(url_for('profile.change_password', user = user)) except Exception as e: flash(str(e), category = 'fail') else: flash('Passwords must match', category = 'fail') return render_template('profile/change_password.html', username = session['username'], role = session['role'], user = user, form = form) return render_template('profile/change_password.html', username = session['username'], role = session['role'], user = user, form = form)
def ChangeForgotPassword(token): form = EnterForms.ChangePassword(request.form) usr = VerifyToken(token) if usr: if request.method == 'POST': if request.form['submit'] == 'Submit' and request.form[ 'newpswd'] == request.form['confirm']: try: ChangePassword1(usr, request.form['newpswd']) flash('Password changed...', category='success') return redirect(url_for('login')) except Exception as e: flash(str(e), category='fail') return redirect(url_for('login')) return render_template('change_forgot_password.html', form=form, token=token) else: return render_template('invalid_token.html')