Oauth Anthentication #48

Merged
Xefir merged 13 commits from v2 into master 2022-09-12 18:47:37 +00:00
1 changed files with 6 additions and 7 deletions
Showing only changes of commit 6775e09c7a - Show all commits

View File

@ -3,7 +3,7 @@ import logging
from datetime import datetime, timedelta
from functools import wraps
from os import environ, path
from typing import Optional
from typing import Dict, List, Optional
from disnake import Client, Guild
from dotenv import load_dotenv
@ -78,7 +78,9 @@ def token_updater(token: str):
session["oauth2_token"] = token
def make_session(token=None, state=None, scope=None) -> OAuth2Session:
def make_session(
token: Optional[Dict[str, str]], state=Optional[str], scope=Optional[List[str]]
) -> OAuth2Session:
return OAuth2Session(
client_id=OAUTH2_CLIENT_ID,
token=token,
@ -176,8 +178,7 @@ async def callback():
@app.route("/guilds")
@login_required
async def guilds():
guild_id = request.args.get("guild")
guild = get_guild_by_id(guild_id)
guild = get_guild_by_id(request.args.get("guild"))
if guild:
return redirect(
@ -212,9 +213,7 @@ async def subscribe(guild_id: str):
if not any(str(guild.id) == user_guild["id"] for user_guild in user_guilds):
return redirect(url_for(".login"))
user = discord.get(f"{API_BASE_URL}/users/@me").json()
return await render_template("subscribe.html.j2", user=user, guild=guild)
return await render_template("subscribe.html.j2", guild=guild)
@app.route("/<guild_id>.ics")