Add actual create-account action.

This commit is contained in:
Sage Vaillancourt 2022-09-23 19:40:07 -04:00
parent a421e25344
commit 32b2455070
1 changed files with 13 additions and 1 deletions

View File

@ -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)