# Copyright (c) 2023-present Plane Software, Inc. and contributors # SPDX-License-Identifier: AGPL-3.0-only # See the LICENSE file for details. # Django imports from django.views import View from django.http import HttpResponseRedirect # Module imports from plane.authentication.utils.host import base_host from plane.authentication.views.nodedc_logout import clear_nodedc_auth_cookies, get_logout_redirect_url, logout_current_user from plane.utils.path_validator import get_safe_redirect_url class SignOutAuthSpaceEndpoint(View): def post(self, request): next_path = request.POST.get("next_path") url = get_safe_redirect_url(base_url=base_host(request=request, is_space=True), next_path=next_path) redirect_url = get_logout_redirect_url(url) try: logout_current_user(request) except Exception: pass response = HttpResponseRedirect(redirect_url) return clear_nodedc_auth_cookies(response, request)