mirror of
https://github.com/gosticks/plane.git
synced 2025-10-16 12:45:33 +00:00
[WEB-4900] refactor: remove base_host retrieval from authentication views (#7804)
* refactor: remove base_host retrieval from authentication views * Removed unnecessary base_host retrieval from GitHub, GitLab, and Google callback endpoints. * Updated MagicSignUpEndpoint to use get_safe_redirect_url for URL construction. * Refactored MagicSignInSpaceEndpoint to streamline URL redirection logic. * refactor: streamline URL redirection in MagicSignInSpaceEndpoint * Removed redundant base_url retrieval from the exception handling in MagicSignInSpaceEndpoint. * Enhanced the clarity of URL construction by directly using get_safe_redirect_url.
This commit is contained in:
parent
1f7eef5f81
commit
56d3a9e049
@ -60,7 +60,6 @@ class GitHubCallbackEndpoint(View):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
code = request.GET.get("code")
|
code = request.GET.get("code")
|
||||||
state = request.GET.get("state")
|
state = request.GET.get("state")
|
||||||
base_host = request.session.get("host")
|
|
||||||
next_path = request.session.get("next_path")
|
next_path = request.session.get("next_path")
|
||||||
|
|
||||||
if state != request.session.get("state", ""):
|
if state != request.session.get("state", ""):
|
||||||
|
|||||||
@ -61,7 +61,6 @@ class GitLabCallbackEndpoint(View):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
code = request.GET.get("code")
|
code = request.GET.get("code")
|
||||||
state = request.GET.get("state")
|
state = request.GET.get("state")
|
||||||
base_host = request.session.get("host")
|
|
||||||
next_path = request.session.get("next_path")
|
next_path = request.session.get("next_path")
|
||||||
|
|
||||||
if state != request.session.get("state", ""):
|
if state != request.session.get("state", ""):
|
||||||
|
|||||||
@ -62,7 +62,6 @@ class GoogleCallbackEndpoint(View):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
code = request.GET.get("code")
|
code = request.GET.get("code")
|
||||||
state = request.GET.get("state")
|
state = request.GET.get("state")
|
||||||
base_host = request.session.get("host")
|
|
||||||
next_path = request.session.get("next_path")
|
next_path = request.session.get("next_path")
|
||||||
|
|
||||||
if state != request.session.get("state", ""):
|
if state != request.session.get("state", ""):
|
||||||
|
|||||||
@ -160,8 +160,6 @@ class MagicSignUpEndpoint(View):
|
|||||||
error_message="USER_ALREADY_EXIST",
|
error_message="USER_ALREADY_EXIST",
|
||||||
)
|
)
|
||||||
params = exc.get_error_dict()
|
params = exc.get_error_dict()
|
||||||
if next_path:
|
|
||||||
params["next_path"] = str(next_path)
|
|
||||||
url = get_safe_redirect_url(
|
url = get_safe_redirect_url(
|
||||||
base_url=base_host(request=request, is_app=True),
|
base_url=base_host(request=request, is_app=True),
|
||||||
next_path=next_path,
|
next_path=next_path,
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
from urllib.parse import urljoin, urlencode
|
|
||||||
|
|
||||||
# Django imports
|
# Django imports
|
||||||
from django.core.validators import validate_email
|
from django.core.validators import validate_email
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
@ -103,10 +101,11 @@ class MagicSignInSpaceEndpoint(View):
|
|||||||
|
|
||||||
except AuthenticationException as e:
|
except AuthenticationException as e:
|
||||||
params = e.get_error_dict()
|
params = e.get_error_dict()
|
||||||
base_url = get_safe_redirect_url(
|
url = get_safe_redirect_url(
|
||||||
base_url=base_host(request=request, is_space=True), next_path=next_path
|
base_url=base_host(request=request, is_space=True),
|
||||||
|
next_path=next_path,
|
||||||
|
params=params,
|
||||||
)
|
)
|
||||||
url = urljoin(base_url, "?" + urlencode(params))
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user