Browse Source

Entra y sale de sesión

Celestino Rey 1 year ago
parent
commit
886ee05cb7

BIN
accounts/__pycache__/urls.cpython-312.pyc


BIN
accounts/__pycache__/views.cpython-312.pyc


+ 7 - 1
accounts/urls.py

@@ -1,8 +1,14 @@
 # accounts/urls.py
 from django.urls import path
 from django.contrib.auth import views as auth_views
+from .views import SignUpView
 
 urlpatterns = [
     path('login/', auth_views.LoginView.as_view(), name='login'),
     path('logout/', auth_views.LogoutView.as_view(), name='logout'),
-]
+    path("signup/", SignUpView.as_view(), name="signup"),
+    path('password_reset/', auth_views.PasswordResetView.as_view(), name='password_reset'),
+    path('password_reset/done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),
+    path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
+    path('reset/done/', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'),
+]

+ 12 - 1
accounts/views.py

@@ -1 +1,12 @@
-from django.shortcuts import render
+# accounts/views.py
+# from django.contrib.auth.forms import UserCreationForm
+from django.urls import reverse_lazy
+from django.views.generic import CreateView
+
+from reymotausers.forms import ReyMotaUserCreationForm
+
+
+class SignUpView(CreateView):
+    form_class = ReyMotaUserCreationForm
+    success_url = reverse_lazy("login")
+    template_name = "registration/signup.html"

BIN
db.sqlite3


BIN
misfinanzas/__pycache__/settings.cpython-312.pyc


+ 2 - 2
misfinanzas/settings.py

@@ -129,8 +129,8 @@ STATICFILES_DIRS = [
 DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
 
 LOGIN_URL = '/accounts/login/'
-LOGIN_REDIRECT_URL = 'principal'
-LOGOUT_REDIRECT_URL = 'principal'
+LOGIN_REDIRECT_URL = 'dashboard'
+LOGOUT_REDIRECT_URL = 'dashboard'
 
 AUTH_USER_MODEL = "reymotausers.ReyMotaUser"
 

+ 2 - 0
misfinanzas/views.py

@@ -0,0 +1,2 @@
+from django.shortcuts import render, get_object_or_404
+

+ 16 - 1
templates/_navigation.html

@@ -21,7 +21,22 @@
             <div class="dropdown-content">
                 {% if user.is_authenticated %}
                 <a class="dropdown-item">{{ user.nombre }}</a>
-                <a href="{% url 'logout' %}">Cerrar Sesión</a>
+                <a href="{% url 'logout' %}">
+                    <form method="post" action="{% url 'logout' %}" >
+                    {% csrf_token %}
+                    <button
+                    style="background: none!important;
+                                border: none;
+                                padding: 0!important;
+                                /*optional*/
+                                font-family: arial, sans-serif;
+                                /*input has OS specific font-family*/
+                                /*color: #069;
+                                text-decoration: underline;*/
+                                cursor: pointer;"   
+                        
+                    type="submit">Salir</button>
+                </form></a>
                 {% else %}
                 <a href="{% url 'login' %}">Iniciar Sesión</a>
                 {% endif %}

+ 12 - 10
templates/registration/logout.html

@@ -1,10 +1,12 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <title>Cerrar Sesión</title>
-</head>
-<body>
-    <h2>Has cerrado sesión con éxito</h2>
-    <a href="{% url 'login' %}">Iniciar sesión nuevamente</a>
-</body>
-</html>
+{% load i18n static %}
+
+{% include "_head.html" %}
+
+<section id="interface">
+    <div class="board">
+        {% include "_menu.html" %}
+        <h2>Has cerrado sesión con éxito</h2>
+        <a href="{% url 'login' %}">Iniciar sesión nuevamente</a>          
+    </div>
+</section>
+{% include "_footer.html" %}