aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views
diff options
context:
space:
mode:
Diffstat (limited to 'pysite/views')
-rw-r--r--pysite/views/main/index.py3
-rw-r--r--pysite/views/main/logout.py15
-rw-r--r--pysite/views/tests/index.py1
3 files changed, 18 insertions, 1 deletions
diff --git a/pysite/views/main/index.py b/pysite/views/main/index.py
index 210eb057..8d0cb349 100644
--- a/pysite/views/main/index.py
+++ b/pysite/views/main/index.py
@@ -1,5 +1,6 @@
# coding=utf-8
from pysite.base_route import RouteView
+from pysite.constants import DISCORD_OAUTH_REDIRECT
class IndexView(RouteView):
@@ -7,4 +8,4 @@ class IndexView(RouteView):
name = "index"
def get(self):
- return self.render("main/index.html")
+ return self.render("main/index.html", login_url=DISCORD_OAUTH_REDIRECT)
diff --git a/pysite/views/main/logout.py b/pysite/views/main/logout.py
new file mode 100644
index 00000000..fce30972
--- /dev/null
+++ b/pysite/views/main/logout.py
@@ -0,0 +1,15 @@
+from flask import redirect, session
+
+from pysite.base_route import RouteView
+
+
+class LogoutView(RouteView):
+ name = "logout"
+ path = "/auth/logout"
+
+ def get(self):
+ if self.logged_in:
+ # remove user's session
+ del session["session_id"]
+ self.oauth.logout()
+ return redirect("/")
diff --git a/pysite/views/tests/index.py b/pysite/views/tests/index.py
index 3071bf0e..2a55a112 100644
--- a/pysite/views/tests/index.py
+++ b/pysite/views/tests/index.py
@@ -7,6 +7,7 @@ from pysite.base_route import RouteView
from pysite.constants import ValidationTypes
from pysite.decorators import api_params
+
SCHEMA = Schema([{"test": str}])
REQUIRED_KEYS = ["test"]