fix: authentication redirection and UI (#4432)

* dev: update python version

* dev: handle magic code attempt exhausted

* dev: update app, space and god mode redirection paths

* fix: handled signup and signin workflow

* chore: auth input error indication and autofill styling improvement

* dev: add app redirection urls

* dev: update redirections

* chore: onboarding improvement

* chore: onboarding improvement

* chore: redirection issue in space resolved

* chore: instance empty state added

* dev: fix app, space, admin redirection in docker setitngs

---------

Co-authored-by: guru_sainath <gurusainath007@gmail.com>
Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia@plane.so>
This commit is contained in:
Nikhil 2024-05-10 17:30:38 +05:30 committed by GitHub
parent 2d1201cc92
commit 88ebda42ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 1336 additions and 541 deletions

View file

@ -42,8 +42,8 @@ class SignInAuthEndpoint(View):
params["next_path"] = str(next_path)
# Base URL join
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode(params),
base_host(request=request, is_app=True),
"sign-in?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -66,8 +66,8 @@ class SignInAuthEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode(params),
base_host(request=request, is_app=True),
"sign-in?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -85,8 +85,8 @@ class SignInAuthEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode(params),
base_host(request=request, is_app=True),
"sign-in?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -100,8 +100,8 @@ class SignInAuthEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode(params),
base_host(request=request, is_app=True),
"sign-in?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -111,7 +111,7 @@ class SignInAuthEndpoint(View):
)
user = provider.authenticate()
# Login the user and record his device info
user_login(request=request, user=user)
user_login(request=request, user=user, is_app=True)
# Process workspace and project invitations
process_workspace_project_invitations(user=user)
# Get the redirection path
@ -121,15 +121,15 @@ class SignInAuthEndpoint(View):
path = get_redirection_path(user=user)
# redirect to referer path
url = urljoin(base_host(request=request), path)
url = urljoin(base_host(request=request, is_app=True), path)
return HttpResponseRedirect(url)
except AuthenticationException as e:
params = e.get_error_dict()
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode(params),
base_host(request=request, is_app=True),
"sign-in?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -152,7 +152,7 @@ class SignUpAuthEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -173,7 +173,7 @@ class SignUpAuthEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -192,7 +192,7 @@ class SignUpAuthEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -207,7 +207,7 @@ class SignUpAuthEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -218,7 +218,7 @@ class SignUpAuthEndpoint(View):
)
user = provider.authenticate()
# Login the user and record his device info
user_login(request=request, user=user)
user_login(request=request, user=user, is_app=True)
# Process workspace and project invitations
process_workspace_project_invitations(user=user)
# Get the redirection path
@ -227,14 +227,14 @@ class SignUpAuthEndpoint(View):
else:
path = get_redirection_path(user=user)
# redirect to referer path
url = urljoin(base_host(request=request), path)
url = urljoin(base_host(request=request, is_app=True), path)
return HttpResponseRedirect(url)
except AuthenticationException as e:
params = e.get_error_dict()
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)

View file

@ -24,7 +24,7 @@ class GitHubOauthInitiateEndpoint(View):
def get(self, request):
# Get host and next path
request.session["host"] = base_host(request=request)
request.session["host"] = base_host(request=request, is_app=True)
next_path = request.GET.get("next_path")
if next_path:
request.session["next_path"] = str(next_path)
@ -42,7 +42,7 @@ class GitHubOauthInitiateEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -57,7 +57,7 @@ class GitHubOauthInitiateEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -110,7 +110,7 @@ class GitHubCallbackEndpoint(View):
)
user = provider.authenticate()
# Login the user and record his device info
user_login(request=request, user=user)
user_login(request=request, user=user, is_app=True)
# Process workspace and project invitations
process_workspace_project_invitations(user=user)
# Get the redirection path

View file

@ -24,7 +24,7 @@ from plane.authentication.adapter.error import (
class GoogleOauthInitiateEndpoint(View):
def get(self, request):
request.session["host"] = base_host(request=request)
request.session["host"] = base_host(request=request, is_app=True)
next_path = request.GET.get("next_path")
if next_path:
request.session["next_path"] = str(next_path)
@ -42,7 +42,7 @@ class GoogleOauthInitiateEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -58,7 +58,7 @@ class GoogleOauthInitiateEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -108,7 +108,7 @@ class GoogleCallbackEndpoint(View):
)
user = provider.authenticate()
# Login the user and record his device info
user_login(request=request, user=user)
user_login(request=request, user=user, is_app=True)
# Process workspace and project invitations
process_workspace_project_invitations(user=user)
# Get the redirection path

View file

@ -90,8 +90,8 @@ class MagicSignInEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode(params),
base_host(request=request, is_app=True),
"sign-in?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -104,8 +104,8 @@ class MagicSignInEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode(params),
base_host(request=request, is_app=True),
"sign-in?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -116,7 +116,7 @@ class MagicSignInEndpoint(View):
user = provider.authenticate()
profile = Profile.objects.get(user=user)
# Login the user and record his device info
user_login(request=request, user=user)
user_login(request=request, user=user, is_app=True)
# Process workspace and project invitations
process_workspace_project_invitations(user=user)
if user.is_password_autoset and profile.is_onboarded:
@ -129,7 +129,7 @@ class MagicSignInEndpoint(View):
else str(process_workspace_project_invitations(user=user))
)
# redirect to referer path
url = urljoin(base_host(request=request), path)
url = urljoin(base_host(request=request, is_app=True), path)
return HttpResponseRedirect(url)
except AuthenticationException as e:
@ -137,8 +137,8 @@ class MagicSignInEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode(params),
base_host(request=request, is_app=True),
"sign-in?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -163,7 +163,7 @@ class MagicSignUpEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -177,7 +177,7 @@ class MagicSignUpEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -188,7 +188,7 @@ class MagicSignUpEndpoint(View):
)
user = provider.authenticate()
# Login the user and record his device info
user_login(request=request, user=user)
user_login(request=request, user=user, is_app=True)
# Process workspace and project invitations
process_workspace_project_invitations(user=user)
# Get the redirection path
@ -197,7 +197,7 @@ class MagicSignUpEndpoint(View):
else:
path = get_redirection_path(user=user)
# redirect to referer path
url = urljoin(base_host(request=request), path)
url = urljoin(base_host(request=request, is_app=True), path)
return HttpResponseRedirect(url)
except AuthenticationException as e:
@ -205,7 +205,7 @@ class MagicSignUpEndpoint(View):
if next_path:
params["next_path"] = str(next_path)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"?" + urlencode(params),
)
return HttpResponseRedirect(url)

View file

@ -146,7 +146,7 @@ class ResetPasswordEndpoint(View):
)
params = exc.get_error_dict()
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"accounts/reset-password?" + urlencode(params),
)
return HttpResponseRedirect(url)
@ -159,8 +159,9 @@ class ResetPasswordEndpoint(View):
error_message="INVALID_PASSWORD",
)
url = urljoin(
base_host(request=request),
"?" + urlencode(exc.get_error_dict()),
base_host(request=request, is_app=True),
"accounts/reset-password?"
+ urlencode(exc.get_error_dict()),
)
return HttpResponseRedirect(url)
@ -172,7 +173,7 @@ class ResetPasswordEndpoint(View):
error_message="INVALID_PASSWORD",
)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"accounts/reset-password?"
+ urlencode(exc.get_error_dict()),
)
@ -184,8 +185,8 @@ class ResetPasswordEndpoint(View):
user.save()
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode({"success": True}),
base_host(request=request, is_app=True),
"sign-in?" + urlencode({"success": True}),
)
return HttpResponseRedirect(url)
except DjangoUnicodeDecodeError:
@ -196,7 +197,7 @@ class ResetPasswordEndpoint(View):
error_message="EXPIRED_PASSWORD_TOKEN",
)
url = urljoin(
base_host(request=request),
base_host(request=request, is_app=True),
"accounts/reset-password?" + urlencode(exc.get_error_dict()),
)
return HttpResponseRedirect(url)

View file

@ -1,5 +1,5 @@
# Python imports
from urllib.parse import urlencode, urljoin
from urllib.parse import urljoin
# Django imports
from django.views import View
@ -23,12 +23,9 @@ class SignOutAuthEndpoint(View):
user.save()
# Log the user out
logout(request)
url = urljoin(
base_host(request=request),
"accounts/sign-in?" + urlencode({"success": "true"}),
)
url = urljoin(base_host(request=request, is_app=True), "sign-in")
return HttpResponseRedirect(url)
except Exception:
return HttpResponseRedirect(
base_host(request=request), "accounts/sign-in"
base_host(request=request, is_app=True), "sign-in"
)