* dev: add admin and space base url * fix: formatting * dev: add app,space and admin base url to the api env * fix: updated app base urls redirection * dev: add change password endpoint * dev: add none as default for base url * dev: space password management endpoints * fix: docker env update * fix: docker and env settings * fix: docker changes * fix: next config update --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: guru_sainath <gurusainath007@gmail.com>
25 lines
736 B
Python
25 lines
736 B
Python
# Python imports
|
|
from urllib.parse import urlsplit
|
|
|
|
# Django imports
|
|
from django.conf import settings
|
|
|
|
|
|
def base_host(request, is_admin=False, is_space=False):
|
|
"""Utility function to return host / origin from the request"""
|
|
|
|
if is_admin and settings.ADMIN_BASE_URL:
|
|
return settings.ADMIN_BASE_URL
|
|
|
|
if is_space and settings.SPACE_BASE_URL:
|
|
return settings.SPACE_BASE_URL
|
|
|
|
return (
|
|
request.META.get("HTTP_ORIGIN")
|
|
or f"{urlsplit(request.META.get('HTTP_REFERER')).scheme}://{urlsplit(request.META.get('HTTP_REFERER')).netloc}"
|
|
or f"""{"https" if request.is_secure() else "http"}://{request.get_host()}"""
|
|
)
|
|
|
|
|
|
def user_ip(request):
|
|
return str(request.META.get("REMOTE_ADDR"))
|