Skip to content

Commit

Permalink
Redirect after login (#309)
Browse files Browse the repository at this point in the history
* chore: changed double quote for readability

* fix: redirect after login

* chore: switched single quote

* chore: removed login redirect url in favor of default value
  • Loading branch information
raffaellasuardini authored Mar 27, 2024
1 parent 9e5b3d2 commit d8014c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

from django.contrib.auth import views as auth_views
from django.urls import include
from django.urls import path

Expand All @@ -10,6 +11,11 @@
from .views import unsubscribe

urlpatterns = [
path(
"login/",
auth_views.LoginView.as_view(redirect_field_name="next_page"),
name="login",
),
path("", include("django.contrib.auth.urls")),
path("profile/", profile, name="profile"),
path("profile/update/", UpdateUserView.as_view(), name="update_user"),
Expand Down
4 changes: 2 additions & 2 deletions indymeet/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@

import os


import dj_database_url
from dotenv import load_dotenv

from django.forms.renderers import TemplatesSetting
from dotenv import load_dotenv

load_dotenv()

Expand Down Expand Up @@ -207,7 +208,6 @@

AUTH_USER_MODEL = "accounts.CustomUser"

LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"

DEFAULT_FROM_EMAIL = "[email protected]"
Expand Down
6 changes: 3 additions & 3 deletions indymeet/templates/includes/nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
<div class="flex items-center gap-4">
<div class="sm:flex sm:gap-4">
{% if "login" not in request.path %}
<a class="hidden rounded-md bg-gray-100 px-5 py-2.5 text-sm font-medium text-ds-purple transition hover:bg-gray-300 sm:block cursor-pointer" href="{% url "login" %}">
<a class="hidden rounded-md bg-gray-100 px-5 py-2.5 text-sm font-medium text-ds-purple transition hover:bg-gray-300 sm:block cursor-pointer" href="{% url 'login' %}?next_page={{request.path}}">
{% trans "Login" %}
</a>
{% endif %}
{% if "signup" not in request.path %}
<a class="block rounded-md bg-primary px-5 py-2.5 text-sm font-medium text-white transition hover:bg-gray-300 hover:text-ds-purple cursor-pointer" href="{% url "signup" %}">
<a class="block rounded-md bg-primary px-5 py-2.5 text-sm font-medium text-white transition hover:bg-gray-300 hover:text-ds-purple cursor-pointer" href="{% url 'signup' %}">
{% trans "Sign Up" %}
</a>
{% endif %}
Expand Down Expand Up @@ -120,7 +120,7 @@
</li>
{% else %}
<li class="p-2">
<a class="block outline-link text-gray-500 transition hover:text-ds-purple" href="{% url 'login' %}">
<a class="block outline-link text-gray-500 transition hover:text-ds-purple" href="{% url 'login'%}?next_page={{request.path}}">
{% trans "Login" %}
</a>
</li>
Expand Down

0 comments on commit d8014c7

Please sign in to comment.