#29 feat(Auth): add logout and profile.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
from django.urls import path, include
|
||||
from django.contrib.auth.views import LoginView
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
from . import views
|
||||
@@ -16,7 +15,6 @@ router.register(r'reconciliate_jar', api_views.ReconciliateJarModelView,
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.index, name="wellcome"),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
path("comprar", views.buy, name="buy"),
|
||||
path("compras", views.purchases, name="purchases"),
|
||||
path("productos", views.products, name="products"),
|
||||
|
||||
@@ -65,7 +65,7 @@ ROOT_URLCONF = 'tienda_ilusion.urls'
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'DIRS': [os.path.join(BASE_DIR, 'tienda_ilusion/templates')],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
@@ -143,3 +143,5 @@ REST_FRAMEWORK = {
|
||||
'rest_framework.permissions.IsAuthenticated',
|
||||
],
|
||||
}
|
||||
|
||||
LOGOUT_REDIRECT_URL = '/start/'
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Perfil de usuario</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<h1>Perfil de usuario</h1>
|
||||
<p>Nombre de usuario: {{ user.username }}</p>
|
||||
<p>Email: {{ user.email }}</p>
|
||||
<form action="{% url 'logout' %}" method="post" style="display: inline-block;">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-danger">Cerrar sesión</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
22
tienda_ilusion/tienda_ilusion/templates/start.html
Normal file
22
tienda_ilusion/tienda_ilusion/templates/start.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bienvenido a la tienda la ilusión</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-8">
|
||||
<h1>Bienvenido a la tienda la ilusion</h1>
|
||||
|
||||
<a href="{% url 'login' %}">Login</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -16,11 +16,15 @@ Including another URLconf
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
from . import views
|
||||
|
||||
|
||||
app_name = "don_confiao"
|
||||
|
||||
urlpatterns = [
|
||||
path("don_confiao/", include("don_confiao.urls")),
|
||||
path("accounts/", include("django.contrib.auth.urls")),
|
||||
path('accounts/profile/', views.ProfileView.as_view(), name='profile'),
|
||||
path('start/', views.StartView.as_view(), name='start'),
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user