mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 12:51:09 -05:00
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from django.core.management.base import BaseCommand
|
|
from allauth.socialaccount.models import SocialApp
|
|
from django.contrib.sites.models import Site
|
|
import os
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Fix social app configurations'
|
|
|
|
def handle(self, *args, **options):
|
|
# Delete all existing social apps
|
|
SocialApp.objects.all().delete()
|
|
self.stdout.write('Deleted all existing social apps')
|
|
|
|
# Get the default site
|
|
site = Site.objects.get(id=1)
|
|
|
|
# Create Google provider
|
|
google_app = SocialApp.objects.create(
|
|
provider='google',
|
|
name='Google',
|
|
client_id=os.getenv('GOOGLE_CLIENT_ID'),
|
|
secret=os.getenv('GOOGLE_CLIENT_SECRET'),
|
|
)
|
|
google_app.sites.add(site)
|
|
self.stdout.write(f'Created Google app with client_id: {google_app.client_id}')
|
|
|
|
# Create Discord provider
|
|
discord_app = SocialApp.objects.create(
|
|
provider='discord',
|
|
name='Discord',
|
|
client_id=os.getenv('DISCORD_CLIENT_ID'),
|
|
secret=os.getenv('DISCORD_CLIENT_SECRET'),
|
|
)
|
|
discord_app.sites.add(site)
|
|
self.stdout.write(f'Created Discord app with client_id: {discord_app.client_id}')
|