Compare commits

...

2 Commits

Author SHA1 Message Date
Danhia 3b86441259 Merge branch 'main' into bot-api 2022-02-18 11:11:58 +01:00
Danhia 7b2552f0b5 added try except in case user cancels oauth 2022-02-18 11:11:34 +01:00
1 changed files with 31 additions and 28 deletions

View File

@ -34,7 +34,10 @@ def connect(request):
def authorize(request):
if request.user.userprofileinfo.discord_id:
return bad_request(request, "Already connected")
try:
token = oauth.discord.authorize_access_token(request)
except:
bad_request(request, "Connection refused")
response = oauth.discord.get('users/@me', token=token)
response = response.json()
discord_id = response['id']