mirror of
https://github.com/yawaflua/Flask-Discord.git
synced 2025-12-09 20:09:30 +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
|
||||
|
||||
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__)
|
||||
|
||||
@@ -69,6 +69,11 @@ in exchange for fetching user's details and display them on web page.
|
||||
return redirect(url_for(".me"))
|
||||
|
||||
|
||||
@app.errorhandler(Unauthorized)
|
||||
def redirect_unauthorized(e):
|
||||
return redirect(url_for("login"))
|
||||
|
||||
|
||||
@app.route("/me/")
|
||||
@requires_authorization
|
||||
def me():
|
||||
@@ -85,4 +90,4 @@ in exchange for fetching user's details and display them on web page.
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
app.run()
|
||||
|
||||
Reference in New Issue
Block a user