diff --git a/shop.py b/shop.py index cb23f13..e9be3ee 100644 --- a/shop.py +++ b/shop.py @@ -408,6 +408,24 @@ def register(): return redirect(url_for('login')) return render_template('register.html', error=error) +@app.route('/profile', methods=['GET', 'POST']) +def profile(): + error = None + if request.method == 'POST': + import re, string + pattern = re.compile('[\W]+') + password=password_hash(request.form['password']) + if len(request.form['password'])<5: + error="Password too short" + return render_template('profile.html', error=error) + g.db.execute('update users set pass=? where id=?', + [password,session.get('user')]) + g.db.commit() + flash('successfully updated profile.') + return redirect(url_for('profile')) + return render_template('profile.html', error=error) + + @app.route('/logout') def logout(): diff --git a/templates/layout.html b/templates/layout.html index 6f34231..7148691 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -12,12 +12,11 @@
+
List shops Reload page + Profile Logout - - -
{% for message in get_flashed_messages() %}
{{ message }}
diff --git a/templates/profile.html b/templates/profile.html new file mode 100644 index 0000000..c261d60 --- /dev/null +++ b/templates/profile.html @@ -0,0 +1,14 @@ +{% extends "layout.html" %} +{% block body %} +

Profile

+ {% if error %}

Error: {{ error }}{% endif %} +

+
+
Username: +
+
Password: +
+
+
+
+{% endblock %} diff --git a/templates/register.html b/templates/register.html index 8a0753a..961711c 100644 --- a/templates/register.html +++ b/templates/register.html @@ -8,7 +8,7 @@
Password:
-
+
{% endblock %}