From 952fd637975ac6be4e30f83d70f9343a0818e1bc Mon Sep 17 00:00:00 2001 From: Benedict Etzel Date: Tue, 14 Jan 2025 08:10:50 +0100 Subject: [PATCH] feat(discord): support action=reauthenticate --- allauth/socialaccount/providers/discord/provider.py | 8 +++++++- docs/socialaccount/templates.rst | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/allauth/socialaccount/providers/discord/provider.py b/allauth/socialaccount/providers/discord/provider.py index 6500d34343..7474429e6d 100644 --- a/allauth/socialaccount/providers/discord/provider.py +++ b/allauth/socialaccount/providers/discord/provider.py @@ -1,5 +1,5 @@ from allauth.account.models import EmailAddress -from allauth.socialaccount.providers.base import ProviderAccount +from allauth.socialaccount.providers.base import AuthAction, ProviderAccount from allauth.socialaccount.providers.discord.views import DiscordOAuth2Adapter from allauth.socialaccount.providers.oauth2.provider import OAuth2Provider @@ -86,6 +86,12 @@ def extract_common_fields(self, data): name=data.get("username"), ) + def get_auth_params_from_request(self, request, action): + ret = super().get_auth_params_from_request(request, action) + if action == AuthAction.REAUTHENTICATE: + ret["prompt"] = "consent" + return ret + def get_default_scope(self): return ["email", "identify"] diff --git a/docs/socialaccount/templates.rst b/docs/socialaccount/templates.rst index a373705234..e3042ba288 100644 --- a/docs/socialaccount/templates.rst +++ b/docs/socialaccount/templates.rst @@ -17,7 +17,7 @@ indicates how to process the social login. You can choose between Furthermore, you can pass along an ``action`` parameter with value ``reauthenticate`` to indicate that you want the user to be re-prompted for authentication even if they already signed in before. For now, this -is supported by Facebook, Google and Twitter only. +is supported by Facebook, Google, Twitter, and Discord only. For Javascript based logins (e.g. when you enable the Facebook JS SDK), you will need to make sure that the required Javascript is