Add authorized property

This commit is contained in:
thecosmos
2019-05-20 21:10:21 +05:30
parent ff6c6a705b
commit 3c5d221b70

View File

@@ -61,13 +61,18 @@ class DiscordOAuth2Session(_http.DiscordOAuth2HttpClient):
def revoke(self): def revoke(self):
"""This method clears current discord token, state and all session data from flask """This method clears current discord token, state and all session data from flask
session <http://flask.pocoo.org/docs/1.0/api/#flask.session>. Which means user will have `session <http://flask.pocoo.org/docs/1.0/api/#flask.session>`_. Which means user will have
to go through discord authorization token grant flow again. to go through discord authorization token grant flow again.
""" """
for session_key in self.SESSION_KEYS: for session_key in self.SESSION_KEYS:
session.pop(session_key) session.pop(session_key)
@property
def authorized(self):
"""A boolean indicating whether current session has authorization token or not."""
return self._make_session().authorized
def fetch_user(self): def fetch_user(self):
return models.User(self.get("/users/@me")) return models.User(self.get("/users/@me"))