Skip to content
Draft
Show file tree
Hide file tree
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
35 changes: 35 additions & 0 deletions dandiapi/api/templates/auth_style/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "auth_style/base.html" %}
{% load allauth %}
{% load i18n %}
{% load static %}
{% block body %}
<div class="flex flex-col sm:flex-row sm:navbar">
<span class="text-center sm:text-left sm:grow">{% include "auth_style/site_name.html" %}</span>
{# TODO: display username and user info #}
{% if user.is_authenticated %}
{% url 'account_logout' as logout_url_ %}
{% if logout_url_ %}
<a class="btn btn-ghost btn-sm" href="{{ logout_url_ }}">
<i class="ri-logout-box-line ri-lg"></i>
{% trans "Sign Out" %}
</a>
{% endif %}
{% else %}
{% url 'account_login' as login_url_ %}
{% if login_url_ %}
<a class="btn btn-ghost btn-sm" href="{{ login_url_ }}">
<i class="ri-user-shared-line ri-lg"></i>
{% trans "Sign In" %}
</a>
{% endif %}
{% endif %}
</div>
<div class="flex flex-col sm:mx-auto sm:w-full sm:max-w-lg">
<div class="my-6 shadow-sm card bg-base-100">
<div class="card-body">
{% block content %}
{% endblock content %}
</div>
</div>
</div>
{% endblock %}
8 changes: 4 additions & 4 deletions dandiapi/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,6 @@
# for convenience serving a site on a subpath.
STATIC_URL = 'static/'

# Make Django and Allauth redirects consistent, but both may be changed.
LOGIN_REDIRECT_URL = '/'
ACCOUNT_LOGOUT_REDIRECT_URL = '/'

CORS_ALLOWED_ORIGINS: list[str] = env.list('DJANGO_CORS_ALLOWED_ORIGINS', cast=str, default=[])
CORS_ALLOWED_ORIGIN_REGEXES: list[str] = env.list(
'DJANGO_CORS_ALLOWED_ORIGIN_REGEXES', cast=str, default=[]
Expand Down Expand Up @@ -183,6 +179,10 @@
'DJANGO_DANDI_DOI_API_PREFIX'
) # This is used by us directly, but not in all circumstances

# Make Django and Allauth redirects consistent, but both may be changed.
LOGIN_REDIRECT_URL = '/'
ACCOUNT_LOGOUT_REDIRECT_URL = DANDI_WEB_APP_URL

# Non-required environment variabless
_dandi_doi_api_url = cast('ParseResult | None', env.url('DJANGO_DANDI_DOI_API_URL', default=None))
DANDI_DOI_API_URL: str | None = urlunparse(_dandi_doi_api_url) if _dandi_doi_api_url else None
Expand Down
2 changes: 2 additions & 0 deletions web/src/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ const dandiRest = {
user.value = null;
localStorage.clear();
}

window.location.href = 'http://localhost:8000/accounts/logout/'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use the env var for the API

},
async me(): Promise<User> {
const { data: user } = await client.get('users/me/');
Expand Down
Loading