aboutsummaryrefslogtreecommitdiffstats
path: root/pysite/views
diff options
context:
space:
mode:
authorGravatar Nate the great <[email protected]>2018-03-29 04:52:29 -0400
committerGravatar Gareth Coles <[email protected]>2018-03-29 09:52:29 +0100
commit1889f3248ae83cc773a5443c6ba0f62834d73b7b (patch)
tree7603d1da7f64006075cf3a8b58548e1a49ca6840 /pysite/views
parentReorder resources.json (diff)
Oauth (#45)
* Creating a OAUTH login for the site. We still need to have a way to fill in credentials however. Signed-off-by: Zwork101 <[email protected]> * How ya like me now Travis? Signed-off-by: Zwork101 <[email protected]> * Fix slight error in database insertion * Revert "Fix slight error in database insertion" (wrong branch) This reverts commit 9ac6cbb * Don't have snekchek working, but I'll try again. Signed-off-by: Zwork101 <[email protected]> * Please enter the commit message for your changes. Lines starting * Adding Oauth2 login to site. * Add prefix * Add prefix * This never happened * Flipping Travis I still can't get snekchek to work locally. * Added a whole bunch of stuff, ready to be used. Signed-off-by: Zwork101 <[email protected]> * Making sessions more secure, and future safe. Signed-off-by: Zwork101 <[email protected]> * Adding some quick stuff Signed-off-by: Zwork101 <[email protected]> * Appease the flake8 gods Signed-off-by: Zwork101 <[email protected]> * Appease the flake8 gods Signed-off-by: Zwork101 <[email protected]> * Whoops Signed-off-by: Zwork101 <[email protected]> * Add comments, fix user_data function. Signed-off-by: Zwork101 <[email protected]> * Whooops, forgot to flake :/ Signed-off-by: Zwork101 <[email protected]> * Make it look nicer, thanks Aperture. Signed-off-by: Zwork101 <[email protected]> * Fixing login issues and added button * Add a OauthMixin to allow for easy data access. Clean stuff up. Signed-off-by: Zwork101 <[email protected]> * Fix a test, and use self.assertEqual rather then self.assertEquals! Signed-off-by: Zwork101 <[email protected]> * Please don't ask how that happened. Signed-off-by: Zwork101 <[email protected]> * Added some tests, moved a bunch of stuff around. Mainly cleaned stuff up. Signed-off-by: Zwork101 <[email protected]> * Add a ton of tests, try to please the coverall gods :D, moved some code into a function for testing. Signed-off-by: Zwork101 <[email protected]> * Just some stupid stuff I missed. Signed-off-by: Zwork101 <[email protected]> * Fix an issue with the test, and add docs Signed-off-by: Zwork101 <[email protected]> * Remove pointless function. (join_user) Signed-off-by: Zwork101 <[email protected]> * Fix test consistency
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"]