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)