Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🎸 add backend login #1008

Merged
merged 2 commits into from
Jul 8, 2022
Merged
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
22 changes: 16 additions & 6 deletions arkid/core/extension/app_protocol.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.views import View
from abc import abstractmethod
from django.urls import re_path
from arkid.core.models import App
from arkid.core.models import App, Tenant
from arkid.settings import LOGIN_URL
from django.http import HttpResponseRedirect
from arkid.core.extension import Extension
Expand Down Expand Up @@ -111,13 +111,23 @@ def get_login_url(self, request, alert):
if not tenant:
return f'{host}{LOGIN_URL}?tenant_id=&next={next_uri}'

if tenant.is_platform_tenant and tenant.id.hex not in request.get_full_path() and \
str(tenant.id) not in request.get_full_path():
return f'{host}{LOGIN_URL}?tenant_id=&next={next_uri}'

token = request.GET.get('token', '')
if not token:
if tenant.slug:
host =get_app_config().get_slug_frontend_host(tenant.slug)
return f'{host}{LOGIN_URL}?&next={next_uri}'
else:
return f'{host}{LOGIN_URL}?tenant_id={tenant.id}&next={next_uri}'
tenant_expand = Tenant.expand_objects.get(id=tenant.id)
if tenant_expand.get('login_url'):
return f"{tenant_expand['login_url']}?tenant_id={tenant.id}&next={next_uri}"
backend_host = get_app_config().get_host()
backend_login_url = '/api/v1/login'
return f"{backend_host}{backend_login_url}?tenant_id={tenant.id}&next={next_uri}"
# if tenant.slug:
# host =get_app_config().get_slug_frontend_host(tenant.slug)
# return f'{host}{LOGIN_URL}?&next={next_uri}'
# else:
# return f'{host}{LOGIN_URL}?tenant_id={tenant.id}&next={next_uri}'

if tenant.slug:
host =get_app_config().get_slug_frontend_host(tenant.slug)
Expand Down