mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-10 04:19:31 +02:00
Added Unauthorized redirect to basic usage
This commit is contained in:
committed by
GitHub
parent
d552a048ee
commit
a0682fc192
@@ -43,7 +43,7 @@ in exchange for fetching user's details and display them on web page.
|
|||||||
.. code-block:: python3
|
.. code-block:: python3
|
||||||
|
|
||||||
from flask import Flask, redirect, url_for
|
from flask import Flask, redirect, url_for
|
||||||
from flask_discord import DiscordOAuth2Session, requires_authorization
|
from flask_discord import DiscordOAuth2Session, requires_authorization, Unauthorized
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
@@ -69,6 +69,11 @@ in exchange for fetching user's details and display them on web page.
|
|||||||
return redirect(url_for(".me"))
|
return redirect(url_for(".me"))
|
||||||
|
|
||||||
|
|
||||||
|
@app.errorhandler(Unauthorized)
|
||||||
|
def redirect_unauthorized(e):
|
||||||
|
return redirect(url_for("login"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/me/")
|
@app.route("/me/")
|
||||||
@requires_authorization
|
@requires_authorization
|
||||||
def me():
|
def me():
|
||||||
@@ -85,4 +90,4 @@ in exchange for fetching user's details and display them on web page.
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run()
|
app.run()
|
||||||
|
|||||||
Reference in New Issue
Block a user