From 32b24550709d3140ed85b1205e72bd2100cbac79 Mon Sep 17 00:00:00 2001 From: Sage Vaillancourt Date: Fri, 23 Sep 2022 19:40:07 -0400 Subject: [PATCH] Add actual create-account action. --- undercover/routes.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/undercover/routes.py b/undercover/routes.py index fb42bec..d645264 100644 --- a/undercover/routes.py +++ b/undercover/routes.py @@ -96,10 +96,22 @@ def index_get(): @writing_blueprint.route('/create_account', methods=['GET']) -def create_account(): +def create_account_page(): return render_template('create_account.jinja2') +@writing_blueprint.route('/create_account', methods=['POST']) +def create_account(): + email = request.form['login'] + user = db.get_user(email) + if user: + return make_response("A user with that email already exists!", 401) + # TODO: Validate email address + db.add_user(email, request.form['password']) + session['username'] = email + return redirect('/') + + @writing_blueprint.route('/dbtest', methods=['GET']) def db_test_get(): response = make_response(db.get_user_letters(1)[0].contents, 200)