diff --git a/backoffice/.envs/local/.django b/backoffice/.envs/local/.django index 35ca74ef..e46eee62 100644 --- a/backoffice/.envs/local/.django +++ b/backoffice/.envs/local/.django @@ -25,3 +25,6 @@ AIRFLOW_BASE_URL=http://airflow-webserver:8080 AIRFLOW_TOKEN=YWlyZmxvdzphaXJmbG93 SERVICENOW_URL=https://cerntraining.service-now.com + +# Frontend +FRONTEND_LOGIN_SUCCESS=http://127.0.0.1:5000/success diff --git a/backoffice/backoffice/users/adapters.py b/backoffice/backoffice/users/adapters.py index 9dda142b..6a8b8c3a 100644 --- a/backoffice/backoffice/users/adapters.py +++ b/backoffice/backoffice/users/adapters.py @@ -24,8 +24,6 @@ def is_open_for_signup( ) -> bool: return getattr(settings, "ACCOUNT_ALLOW_REGISTRATION", True) - - def populate_user( self, request: HttpRequest, diff --git a/backoffice/backoffice/users/api/views.py b/backoffice/backoffice/users/api/views.py index 0ecd2ac9..4a0af5e4 100644 --- a/backoffice/backoffice/users/api/views.py +++ b/backoffice/backoffice/users/api/views.py @@ -1,16 +1,9 @@ -import requests -from urllib.parse import urljoin -from django.urls import reverse - -from allauth.socialaccount.providers.oauth2.client import OAuth2Client -from allauth.socialaccount.providers.orcid.views import OrcidOAuth2Adapter from django.contrib.auth import get_user_model from rest_framework import status from rest_framework.decorators import action from rest_framework.mixins import ListModelMixin, RetrieveModelMixin, UpdateModelMixin from rest_framework.response import Response from rest_framework.viewsets import GenericViewSet -from rest_framework.views import APIView from backoffice.users.api.serializers import UserSerializer User = get_user_model() diff --git a/backoffice/backoffice/users/views.py b/backoffice/backoffice/users/views.py index 2c043c89..5198254a 100644 --- a/backoffice/backoffice/users/views.py +++ b/backoffice/backoffice/users/views.py @@ -41,10 +41,4 @@ class UserRedirectView(LoginRequiredMixin, RedirectView): def get_redirect_url(self): return reverse("users:detail", kwargs={"pk": self.request.user.pk}) -def success(request): - import ipdb;ipdb.set_trace() - return JsonResponse(data={"wow":request.user.email}) - user_redirect_view = UserRedirectView.as_view() - - diff --git a/backoffice/config/settings/base.py b/backoffice/config/settings/base.py index a4879d49..73bf4481 100644 --- a/backoffice/config/settings/base.py +++ b/backoffice/config/settings/base.py @@ -95,13 +95,12 @@ "allauth", "allauth.account", "allauth.socialaccount", - "allauth.headless", - "allauth.socialaccount.providers.orcid", "django_celery_beat", "rest_framework", "rest_framework.authtoken", "corsheaders", "drf_spectacular", + "allauth.socialaccount.providers.orcid", "django_prometheus", "django_opensearch_dsl", "django_elasticsearch_dsl_drf", @@ -109,14 +108,6 @@ "django_json_widget", ] -REST_AUTH = { - "SESSION_LOGIN": True, - "USE_JWT": True, - "JWT_AUTH_COOKIE": "auth", - 'JWT_AUTH_REFRESH_COOKIE': 'my-refresh-token', - "JWT_AUTH_HTTPONLY": False, -} - LOCAL_APPS = ["backoffice.users", "backoffice.workflows", "backoffice.management"] # https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS @@ -136,7 +127,7 @@ # https://docs.djangoproject.com/en/dev/ref/settings/#auth-user-model AUTH_USER_MODEL = "users.User" # https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url -LOGIN_REDIRECT_URL = "http://127.0.0.1:5000/success" +LOGIN_REDIRECT_URL = env("FRONTEND_LOGIN_SUCCESS") # https://docs.djangoproject.com/en/dev/ref/settings/#login-url LOGIN_URL = "account_login" @@ -340,7 +331,7 @@ # https://django-allauth.readthedocs.io/en/latest/configuration.html ACCOUNT_USER_MODEL_USERNAME_FIELD = None # https://django-allauth.readthedocs.io/en/latest/configuration.html -ACCOUNT_EMAIL_VERIFICATION = "mandatory" +ACCOUNT_EMAIL_VERIFICATION = False # https://django-allauth.readthedocs.io/en/latest/configuration.html ACCOUNT_ADAPTER = "backoffice.users.adapters.AccountAdapter" # https://django-allauth.readthedocs.io/en/latest/forms.html @@ -391,8 +382,6 @@ "BASE_DOMAIN": "sandbox.orcid.org" } } -SOCIALACCOUNT_EMAIL_VERIFICATION = False -ACCOUNT_EMAIL_VERIFICATION = False # Opensearch diff --git a/backoffice/config/urls.py b/backoffice/config/urls.py index dd60de65..1331c921 100644 --- a/backoffice/config/urls.py +++ b/backoffice/config/urls.py @@ -10,8 +10,6 @@ from rest_framework.authtoken.views import obtain_auth_token from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView -from backoffice.users.views import success - urlpatterns = [ path("", TemplateView.as_view(template_name="pages/home.html"), name="home"), path( @@ -32,7 +30,6 @@ # API URLS urlpatterns += [ # API base url - path("accounts/login/success/",success), path("api/oauth/authorized/orcid/", oauth2_callback, name="orcid_callback"), path("api/", include("config.search_router")), path("api/", include("config.api_router")), @@ -46,7 +43,6 @@ ), path("api/token/", TokenObtainPairView.as_view(), name="token_obtain_pair"), path("api/token/refresh/", TokenRefreshView.as_view(), name="token_refresh"), - path("_allauth/", include("allauth.headless.urls")), ]