diff --git a/solvable/src/webservice/server.py b/solvable/src/webservice/server.py index d7d1361..cde4b42 100644 --- a/solvable/src/webservice/server.py +++ b/solvable/src/webservice/server.py @@ -36,7 +36,10 @@ def index(): @app.route('/register', methods=['GET', 'POST']) def register(): if request.method == 'POST': - validate_register_fields(request.form.to_dict()) + if not all([request.form.get('username'), request.form.get('password'), request.form.get('passwordconfirm')]): + return render_template('register.html', alert='You need to fill everything.') + if request.form['password'] != request.form['passwordconfirm']: + return render_template('register.html', alert='Passwords do not match! Please try again.') with Session() as db: if db.query(User).filter(User.username == request.form['username']).all(): @@ -51,13 +54,6 @@ def register(): return render_template('register.html') -def validate_register_fields(request): - if not request.form['username'] or not request.form['password'] or not request.form['passwordconfirm']: - return render_template('register.html', alert='You need to fill everything.') - if request.form['password'] != request.form['passwordconfirm']: - return render_template('register.html', alert='Passwords do not match! Please try again.') - - @app.route('/logout') def logout(): try: