Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion forum/forum/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.github',
'allauth.socialaccount.providers.google',
'rest_framework',
'rest_framework_simplejwt',
'rest_framework_simplejwt.token_blacklist',
Expand All @@ -58,6 +64,7 @@
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"allauth.account.middleware.AccountMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
Expand Down Expand Up @@ -258,4 +265,34 @@
}
}
},
}
}

SITE_ID = 1

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)

SOCIALACCOUNT_PROVIDERS = {
'github': {
'APP': {
'client_id': os.getenv('GITHUB_CLIENT_ID'),
'secret': os.getenv('GITHUB_CLIENT_SECRET'),
'key': ''
}
},
'google': {
'APP': {
'client_id': os.getenv('GOOGLE_CLIENT_ID'),
'secret': os.getenv('GOOGLE_CLIENT_SECRET'),
'key': ''
}
}
}

ACCOUNT_LOGIN_METHODS = {'email'}
ACCOUNT_SIGNUP_FIELDS = ['email*', 'password1*', 'password2*']
ACCOUNT_USER_MODEL_USERNAME_FIELD = None

LOGIN_REDIRECT_URL = '/'
1 change: 1 addition & 0 deletions forum/forum/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@
path('api/users/', include('users.urls')),
path("api/startups/", include('startups.urls')),
path("api/investors/", include('investors.urls')),
path('accounts/', include('allauth.urls')),
]
3 changes: 2 additions & 1 deletion forum/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ djangorestframework-simplejwt==5.3.1
channels==4.0.0
daphne==4.0.0
drf-spectacular==0.28.0

django-allauth==65.9.0
requests==2.32.4
2 changes: 1 addition & 1 deletion forum/startups/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def create(self, request, *args, **kwargs):
- 401 Unauthorized: Authentication credentials were not provided.
- 403 Forbidden: Access denied.
"""
if request.user.role != 2:
if request.user.roles != 2:
return Response(
{"detail": "Only users with role=2 can create startup profiles."},
status=403
Expand Down
23 changes: 23 additions & 0 deletions forum/users/migrations/0002_remove_user_role_user_roles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.21 on 2025-06-27 09:53

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('users', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='user',
name='role',
),
migrations.AddField(
model_name='user',
name='roles',
field=django.contrib.postgres.fields.ArrayField(base_field=models.PositiveSmallIntegerField(choices=[(1, 'Investor'), (2, 'Startup')]), blank=True, default=list, size=None),
),
]
2 changes: 1 addition & 1 deletion forum/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class User(AbstractBaseUser, PermissionsMixin):

USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['user_name']
REQUIRED_FIELDS = []

user_id = models.AutoField(primary_key=True)
email = models.EmailField(unique=True)
Expand Down