forked from github/plane
Merge branch 'preview' of github.com:makeplane/plane into preview
This commit is contained in:
commit
0b84142dce
@ -269,6 +269,7 @@ class ProfileEndpoint(BaseAPIView):
|
|||||||
serializer = ProfileSerializer(profile)
|
serializer = ProfileSerializer(profile)
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
|
@invalidate_cache("/api/users/me/settings/")
|
||||||
def patch(self, request):
|
def patch(self, request):
|
||||||
profile = Profile.objects.get(user=request.user)
|
profile = Profile.objects.get(user=request.user)
|
||||||
serializer = ProfileSerializer(
|
serializer = ProfileSerializer(
|
||||||
|
@ -57,6 +57,8 @@ class EmailCheckSignUpEndpoint(APIView):
|
|||||||
],
|
],
|
||||||
error_message="USER_ACCOUNT_DEACTIVATED",
|
error_message="USER_ACCOUNT_DEACTIVATED",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Raise user already exist
|
||||||
raise AuthenticationException(
|
raise AuthenticationException(
|
||||||
error_code=AUTHENTICATION_ERROR_CODES[
|
error_code=AUTHENTICATION_ERROR_CODES[
|
||||||
"USER_ALREADY_EXIST"
|
"USER_ALREADY_EXIST"
|
||||||
@ -120,7 +122,7 @@ class EmailCheckSignInEndpoint(APIView):
|
|||||||
],
|
],
|
||||||
error_message="USER_ACCOUNT_DEACTIVATED",
|
error_message="USER_ACCOUNT_DEACTIVATED",
|
||||||
)
|
)
|
||||||
|
# Return true
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"status": True,
|
"status": True,
|
||||||
@ -128,6 +130,8 @@ class EmailCheckSignInEndpoint(APIView):
|
|||||||
},
|
},
|
||||||
status=status.HTTP_200_OK,
|
status=status.HTTP_200_OK,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Raise error
|
||||||
raise AuthenticationException(
|
raise AuthenticationException(
|
||||||
error_code=AUTHENTICATION_ERROR_CODES["USER_DOES_NOT_EXIST"],
|
error_code=AUTHENTICATION_ERROR_CODES["USER_DOES_NOT_EXIST"],
|
||||||
error_message="USER_DOES_NOT_EXIST",
|
error_message="USER_DOES_NOT_EXIST",
|
||||||
|
@ -215,6 +215,7 @@ class SignUpAuthEndpoint(View):
|
|||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
# Existing user
|
||||||
existing_user = User.objects.filter(email=email).first()
|
existing_user = User.objects.filter(email=email).first()
|
||||||
|
|
||||||
if existing_user:
|
if existing_user:
|
||||||
|
@ -99,22 +99,6 @@ class MagicSignInEndpoint(View):
|
|||||||
existing_user = User.objects.filter(email=email).first()
|
existing_user = User.objects.filter(email=email).first()
|
||||||
|
|
||||||
if not existing_user:
|
if not existing_user:
|
||||||
if not existing_user.is_active:
|
|
||||||
exc = AuthenticationException(
|
|
||||||
error_code=AUTHENTICATION_ERROR_CODES[
|
|
||||||
"USER_ACCOUNT_DEACTIVATED"
|
|
||||||
],
|
|
||||||
error_message="USER_ACCOUNT_DEACTIVATED",
|
|
||||||
)
|
|
||||||
params = exc.get_error_dict()
|
|
||||||
if next_path:
|
|
||||||
params["next_path"] = str(next_path)
|
|
||||||
url = urljoin(
|
|
||||||
base_host(request=request, is_app=True),
|
|
||||||
"sign-in?" + urlencode(params),
|
|
||||||
)
|
|
||||||
return HttpResponseRedirect(url)
|
|
||||||
|
|
||||||
exc = AuthenticationException(
|
exc = AuthenticationException(
|
||||||
error_code=AUTHENTICATION_ERROR_CODES["USER_DOES_NOT_EXIST"],
|
error_code=AUTHENTICATION_ERROR_CODES["USER_DOES_NOT_EXIST"],
|
||||||
error_message="USER_DOES_NOT_EXIST",
|
error_message="USER_DOES_NOT_EXIST",
|
||||||
@ -128,6 +112,22 @@ class MagicSignInEndpoint(View):
|
|||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
if not existing_user.is_active:
|
||||||
|
exc = AuthenticationException(
|
||||||
|
error_code=AUTHENTICATION_ERROR_CODES[
|
||||||
|
"USER_ACCOUNT_DEACTIVATED"
|
||||||
|
],
|
||||||
|
error_message="USER_ACCOUNT_DEACTIVATED",
|
||||||
|
)
|
||||||
|
params = exc.get_error_dict()
|
||||||
|
if next_path:
|
||||||
|
params["next_path"] = str(next_path)
|
||||||
|
url = urljoin(
|
||||||
|
base_host(request=request, is_app=True),
|
||||||
|
"sign-in?" + urlencode(params),
|
||||||
|
)
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
provider = MagicCodeProvider(
|
provider = MagicCodeProvider(
|
||||||
request=request, key=f"magic_{email}", code=code
|
request=request, key=f"magic_{email}", code=code
|
||||||
@ -189,22 +189,6 @@ class MagicSignUpEndpoint(View):
|
|||||||
# Existing user
|
# Existing user
|
||||||
existing_user = User.objects.filter(email=email).first()
|
existing_user = User.objects.filter(email=email).first()
|
||||||
if not existing_user:
|
if not existing_user:
|
||||||
if not existing_user.is_active:
|
|
||||||
exc = AuthenticationException(
|
|
||||||
error_code=AUTHENTICATION_ERROR_CODES[
|
|
||||||
"USER_ACCOUNT_DEACTIVATED"
|
|
||||||
],
|
|
||||||
error_message="USER_ACCOUNT_DEACTIVATED",
|
|
||||||
)
|
|
||||||
params = exc.get_error_dict()
|
|
||||||
if next_path:
|
|
||||||
params["next_path"] = str(next_path)
|
|
||||||
url = urljoin(
|
|
||||||
base_host(request=request, is_app=True),
|
|
||||||
"?" + urlencode(params),
|
|
||||||
)
|
|
||||||
return HttpResponseRedirect(url)
|
|
||||||
|
|
||||||
exc = AuthenticationException(
|
exc = AuthenticationException(
|
||||||
error_code=AUTHENTICATION_ERROR_CODES["USER_ALREADY_EXIST"],
|
error_code=AUTHENTICATION_ERROR_CODES["USER_ALREADY_EXIST"],
|
||||||
error_message="USER_ALREADY_EXIST",
|
error_message="USER_ALREADY_EXIST",
|
||||||
|
@ -176,23 +176,8 @@ class MagicSignUpSpaceEndpoint(View):
|
|||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
# Existing User
|
# Existing User
|
||||||
existing_user = User.objects.filter(email=email).first()
|
existing_user = User.objects.filter(email=email).first()
|
||||||
|
# Already existing
|
||||||
if existing_user:
|
if existing_user:
|
||||||
if not existing_user.is_active:
|
|
||||||
exc = AuthenticationException(
|
|
||||||
error_code=AUTHENTICATION_ERROR_CODES[
|
|
||||||
"USER_ACCOUNT_DEACTIVATED"
|
|
||||||
],
|
|
||||||
error_message="USER_ACCOUNT_DEACTIVATED",
|
|
||||||
)
|
|
||||||
params = exc.get_error_dict()
|
|
||||||
if next_path:
|
|
||||||
params["next_path"] = str(next_path)
|
|
||||||
url = urljoin(
|
|
||||||
base_host(request=request, is_space=True),
|
|
||||||
"?" + urlencode(params),
|
|
||||||
)
|
|
||||||
return HttpResponseRedirect(url)
|
|
||||||
|
|
||||||
exc = AuthenticationException(
|
exc = AuthenticationException(
|
||||||
error_code=AUTHENTICATION_ERROR_CODES["USER_ALREADY_EXIST"],
|
error_code=AUTHENTICATION_ERROR_CODES["USER_ALREADY_EXIST"],
|
||||||
error_message="USER_ALREADY_EXIST",
|
error_message="USER_ALREADY_EXIST",
|
||||||
|
@ -11,13 +11,14 @@ class InstanceSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Instance
|
model = Instance
|
||||||
fields = "__all__"
|
exclude = [
|
||||||
read_only_fields = [
|
|
||||||
"id",
|
|
||||||
"instance_id",
|
|
||||||
"license_key",
|
"license_key",
|
||||||
"api_key",
|
"api_key",
|
||||||
"version",
|
"version",
|
||||||
|
]
|
||||||
|
read_only_fields = [
|
||||||
|
"id",
|
||||||
|
"instance_id",
|
||||||
"email",
|
"email",
|
||||||
"last_checked_at",
|
"last_checked_at",
|
||||||
"is_setup_done",
|
"is_setup_done",
|
||||||
|
@ -107,7 +107,7 @@ class InstanceAdminSignUpEndpoint(View):
|
|||||||
)
|
)
|
||||||
url = urljoin(
|
url = urljoin(
|
||||||
base_host(request=request, is_admin=True),
|
base_host(request=request, is_admin=True),
|
||||||
"setup?" + urlencode(exc.get_error_dict()),
|
"?" + urlencode(exc.get_error_dict()),
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ class InstanceAdminSignUpEndpoint(View):
|
|||||||
)
|
)
|
||||||
url = urljoin(
|
url = urljoin(
|
||||||
base_host(request=request, is_admin=True),
|
base_host(request=request, is_admin=True),
|
||||||
"setup?" + urlencode(exc.get_error_dict()),
|
"?" + urlencode(exc.get_error_dict()),
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ class InstanceAdminSignUpEndpoint(View):
|
|||||||
)
|
)
|
||||||
url = urljoin(
|
url = urljoin(
|
||||||
base_host(request=request, is_admin=True),
|
base_host(request=request, is_admin=True),
|
||||||
"setup?" + urlencode(exc.get_error_dict()),
|
"?" + urlencode(exc.get_error_dict()),
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ class InstanceAdminSignUpEndpoint(View):
|
|||||||
)
|
)
|
||||||
url = urljoin(
|
url = urljoin(
|
||||||
base_host(request=request, is_admin=True),
|
base_host(request=request, is_admin=True),
|
||||||
"setup?" + urlencode(exc.get_error_dict()),
|
"?" + urlencode(exc.get_error_dict()),
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ class InstanceAdminSignUpEndpoint(View):
|
|||||||
)
|
)
|
||||||
url = urljoin(
|
url = urljoin(
|
||||||
base_host(request=request, is_admin=True),
|
base_host(request=request, is_admin=True),
|
||||||
"setup?" + urlencode(exc.get_error_dict()),
|
"?" + urlencode(exc.get_error_dict()),
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
else:
|
else:
|
||||||
@ -214,7 +214,7 @@ class InstanceAdminSignUpEndpoint(View):
|
|||||||
)
|
)
|
||||||
url = urljoin(
|
url = urljoin(
|
||||||
base_host(request=request, is_admin=True),
|
base_host(request=request, is_admin=True),
|
||||||
"setup?" + urlencode(exc.get_error_dict()),
|
"?" + urlencode(exc.get_error_dict()),
|
||||||
)
|
)
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ class InstanceEndpoint(BaseAPIView):
|
|||||||
def get(self, request):
|
def get(self, request):
|
||||||
instance = Instance.objects.first()
|
instance = Instance.objects.first()
|
||||||
|
|
||||||
print("Instance: ", instance)
|
|
||||||
# get the instance
|
# get the instance
|
||||||
if instance is None:
|
if instance is None:
|
||||||
return Response(
|
return Response(
|
||||||
@ -56,8 +55,6 @@ class InstanceEndpoint(BaseAPIView):
|
|||||||
IS_GITHUB_ENABLED,
|
IS_GITHUB_ENABLED,
|
||||||
GITHUB_APP_NAME,
|
GITHUB_APP_NAME,
|
||||||
EMAIL_HOST,
|
EMAIL_HOST,
|
||||||
EMAIL_HOST_USER,
|
|
||||||
EMAIL_HOST_PASSWORD,
|
|
||||||
ENABLE_MAGIC_LINK_LOGIN,
|
ENABLE_MAGIC_LINK_LOGIN,
|
||||||
ENABLE_EMAIL_PASSWORD,
|
ENABLE_EMAIL_PASSWORD,
|
||||||
SLACK_CLIENT_ID,
|
SLACK_CLIENT_ID,
|
||||||
@ -83,14 +80,6 @@ class InstanceEndpoint(BaseAPIView):
|
|||||||
"key": "EMAIL_HOST",
|
"key": "EMAIL_HOST",
|
||||||
"default": os.environ.get("EMAIL_HOST", ""),
|
"default": os.environ.get("EMAIL_HOST", ""),
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"key": "EMAIL_HOST_USER",
|
|
||||||
"default": os.environ.get("EMAIL_HOST_USER", ""),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "EMAIL_HOST_PASSWORD",
|
|
||||||
"default": os.environ.get("EMAIL_HOST_PASSWORD", ""),
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"key": "ENABLE_MAGIC_LINK_LOGIN",
|
"key": "ENABLE_MAGIC_LINK_LOGIN",
|
||||||
"default": os.environ.get("ENABLE_MAGIC_LINK_LOGIN", "1"),
|
"default": os.environ.get("ENABLE_MAGIC_LINK_LOGIN", "1"),
|
||||||
|
Loading…
Reference in New Issue
Block a user