diff --git a/app.py b/app.py index a6ff3a7..e16eed8 100644 --- a/app.py +++ b/app.py @@ -7,7 +7,7 @@ from flask_htmx import HTMX import requests from db import DataBase from services import create_http_function_view_model, create_http_functions_view_model -from flask_login import LoginManager, UserMixin, current_user, login_required, login_user +from flask_login import LoginManager, UserMixin, current_user, login_required, login_user, logout_user from werkzeug.security import check_password_hash, generate_password_hash login_manager = LoginManager() @@ -342,6 +342,12 @@ def signup(): return redirect(url_for('dashboard')) +@app.route("/logout") +@login_required +def logout(): + logout_user() + return redirect(url_for('home')) + @login_manager.user_loader def load_user(user_id): diff --git a/db.py b/db.py index 024ef78..1b432f0 100644 --- a/db.py +++ b/db.py @@ -103,5 +103,5 @@ ORDER BY invocation_time DESC""", [http_function_id]) def create_new_user(self, username, password_hash): new_user = self.execute( - 'INSERT INTO users (username, password_hash) VALUES (%s, %s) RETURNING id, username, password_hash, created_at', [username, password_hash], commit=True) + 'INSERT INTO users (username, password_hash) VALUES (%s, %s) RETURNING id, username, password_hash, created_at', [username, password_hash], commit=True, one=True) return new_user \ No newline at end of file diff --git a/templates/dashboard.html b/templates/dashboard.html index a1953a3..80105a4 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -73,10 +73,10 @@ Home
-
{{ render_partial('dashboard/http_functions.html', http_functions=http_functions) }} diff --git a/templates/dashboard/http_functions.html b/templates/dashboard/http_functions.html index 74ace67..b6daf62 100644 --- a/templates/dashboard/http_functions.html +++ b/templates/dashboard/http_functions.html @@ -82,6 +82,16 @@ {% endfor %} + + {% if http_functions|length == 0 %} +
+ + No functions found + +
+ {% endif %} +