diff --git a/servicePoints/templates/delete.html b/servicePoints/templates/delete.html new file mode 100644 index 0000000000000000000000000000000000000000..9a5db10b0d93eed24a9f6b87e5e5e940391fd1a0 --- /dev/null +++ b/servicePoints/templates/delete.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<html> + <head> + <link rel="stylesheet" type="text/css" href="/css/style.css"> + <title>ServicePoints</title> + </head> + + <body> + <h1> + <a href="/">/ </a> + | + <a href="/u/{{username}}/">{{username}}</a> + </h1> + <p>{{username}}</p> + <p> + {{username}} + </p> + <form action="/accounts/delete/" method="post" enctype="multipart/form-data"> + <input type="submit" name="delete" value="confirm delete account"/> + </form> + </body> +</html> diff --git a/servicePoints/templates/index.html b/servicePoints/templates/index.html index bf50a78dd674afddc51e9565a124794a0eeecd3d..47ab30efc26f15ef11fadd352e1bd8bb52131f33 100644 --- a/servicePoints/templates/index.html +++ b/servicePoints/templates/index.html @@ -4,5 +4,6 @@ <link rel="stylesheet" type="text/css" href="/css/style.css"> <title>ServicePoints</title> <a href="/accounts/logout/">logout</a> + <a href="/accounts/delete/">delete</a> </head> </html> diff --git a/servicePoints/views/__pycache__/accounts.cpython-36.pyc b/servicePoints/views/__pycache__/accounts.cpython-36.pyc index 5fba22d061eb399d26ed5f24624065c794a7dfca..394d327d3d65b11945112c8fd0612b5e23813cc9 100644 Binary files a/servicePoints/views/__pycache__/accounts.cpython-36.pyc and b/servicePoints/views/__pycache__/accounts.cpython-36.pyc differ diff --git a/servicePoints/views/accounts.py b/servicePoints/views/accounts.py index b3960bc44f2ca1eae716792aa5d88c15fc47144d..6bfa5b97b50ed2a07264545d87d2483b0c597506 100644 --- a/servicePoints/views/accounts.py +++ b/servicePoints/views/accounts.py @@ -105,3 +105,17 @@ def hash_pass(password_in): password_hash = hash_obj.hexdigest() password_db_string = "$".join([algorithm, salt, password_hash]) return password_db_string + +@servicePoints.app.route('/accounts/delete/', methods=['GET', 'POST']) +def delete(): + """Render delete page.""" + if flask.request.method == 'POST': + name = (flask.session['username']) + to_add = (name,) + cur = servicePoints.model.get_db() + + flask.session.clear() + cur.execute('DELETE FROM users WHERE username=?', to_add) + return flask.redirect(flask.url_for('create')) + context = {'username': flask.session['username']} + return render_template('delete.html', **context) \ No newline at end of file diff --git a/var/servicePoints.sqlite3 b/var/servicePoints.sqlite3 index 8c0b335ad8cf3043d2bba7171a82254b229827b0..9e8299e1f860840844facfaaf6e31a9c86477411 100644 Binary files a/var/servicePoints.sqlite3 and b/var/servicePoints.sqlite3 differ