Skip to content

Commit

Permalink
Merge pull request EGCETSII#16 from Full-Tortuga/feature/initialtemplate
Browse files Browse the repository at this point in the history
Solucion errores en landing page
  • Loading branch information
moncalvillo authored Dec 21, 2021
2 parents 62fa4fa + a48bad9 commit b9e15f9
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ coverage.xml

# Django stuff:
*.log
local_settings.py
decide/local_settings.py

migrations/

Expand Down Expand Up @@ -104,4 +104,4 @@ ENV/
# mypy
.mypy_cache/

.vagrant
.vagrant
20 changes: 13 additions & 7 deletions decide/authentication/templates/bienvenida.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

{% block content %}

{% if user.is_authenticated %}
<h1>Hola {{ user.username }}</h1>
<a href="">Cerrar sesión</a>
{% else %}
<a href="{% url 'sign_up' %}">Registrate</a>
<a href="{% url 'sign_in' %}">Iniciar sesión</a>
{% endif %}
<ul>
{% if user.is_authenticated %}
<h1>Hola {{ user.first_name }}</h1>

<a href="{% url 'logout' %}">Cerrar sesión</a>
{% else %}
<a href="{% url 'sign_in' %}">Registrate</a>
<a href="{% url 'sign_in' %}">Iniciar sesión con usuario/contraseña</a>
<a href="{% url 'loginldap' %}">Iniciar sesión con LDAP</a>
<a href="">Iniciar sesión con huella dactilar</a>{% comment %}Meter url huelladactilar {% endcomment %}
<a href="">Iniciar sesión con redes sociales</a>{% comment %}Meter url para rrss {% endcomment %}
{% endif %}
</ul>

{% endblock content %}
13 changes: 8 additions & 5 deletions decide/authentication/urls.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from django.contrib.auth import views
from django.urls import include, path
from rest_framework.authtoken.views import obtain_auth_token

from .views import BienvenidaView, GetUserView, LogoutView, RegisterView, LDAPLogin, SignInView
from .views import BienvenidaView, GetUserView, LogoutView, RegisterView, LDAPLogin, SignInView, cerrarsesion, inicio


urlpatterns = [
path('login/', obtain_auth_token),
path('logout/', LogoutView.as_view()),
# path('logout/', LogoutView.as_view(), name='logout'),
path('getuser/', GetUserView.as_view()),
path('register/', RegisterView.as_view()),
path('loginLDAP/', LDAPLogin.as_view()),
path('login_form/', SignInView.as_view()),
path('register/', RegisterView.as_view(), name='sign_up'),
path('loginLDAP/', LDAPLogin.as_view(), name="loginldap"),
path('login_form/', SignInView.as_view(), name='sign_in'),
path('bienvenida/', BienvenidaView.as_view()),
path('logout/', cerrarsesion, name="logout"),
# path('', inicio),
]
7 changes: 7 additions & 0 deletions decide/authentication/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.db import IntegrityError
from django.shortcuts import get_object_or_404
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth import login, logout

from .serializers import UserSerializer

Expand Down Expand Up @@ -61,6 +62,7 @@ def post(self, request):
from rest_framework.views import APIView
from django.shortcuts import render, redirect
from django.contrib.auth.views import LoginView
from django.contrib import messages

from django.views.generic import TemplateView

Expand Down Expand Up @@ -107,3 +109,8 @@ class SignInView(LoginView):

class BienvenidaView(TemplateView):
template_name = 'bienvenida.html'

def cerrarsesion(request):
logout(request)
messages.success(request, F"Su sesión se ha cerrado correctamente")
return render(request, "bienvenida.html")
60 changes: 43 additions & 17 deletions decide/local_settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ldap
from django_auth_ldap.config import LDAPSearch, GroupOfNamesType
ALLOWED_HOSTS = ["*"]

CORS_ORIGIN_ALLOW_ALL = True

# Modules in use, commented modules that you won't use
'''MODULES = [
MODULES = [
'authentication',
'base',
'booth',
Expand All @@ -13,34 +13,60 @@
'store',
'visualizer',
'voting',
]'''
]

APIS = {
'authentication': 'http://localhost:8011',
'base': 'http://localhost:8011',
'booth': 'http://localhost:8011',
'census': 'http://localhost:8011',
'mixnet': 'http://localhost:8011',
'postproc': 'http://localhost:8011',
'store': 'http://localhost:8011',
'visualizer': 'http://localhost:8011',
'voting': 'http://localhost:8011',
'authentication': 'http://localhost:8000',
'base': 'http://localhost:8000',
'booth': 'http://localhost:8000',
'census': 'http://localhost:8000',
'mixnet': 'http://localhost:8000',
'postproc': 'http://localhost:8000',
'store': 'http://localhost:8000',
'visualizer': 'http://localhost:8000',
'voting': 'http://localhost:8000',
}

BASEURL = 'http://localhost:8011'
BASEURL = 'http://localhost:8000'

DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'decide',
'CLIENT': {
'host': '172.31.0.2',
'username': 'mongo',
'password': 'mongo'
'host': 'mongodb://127.0.0.1:27017/decide?compressors=disabled&gssapiServiceName=mongodb',
'username': 'decide',
'password': 'decide'
}

}
}

# number of bits for the key, all auths should use the same number of bits
KEYBITS = 256

AUTH_LDAP_SERVER_URI = 'ldap://:388'

AUTH_LDAP_BIND_DN = 'cn=admin,dc=decide,dc=org'
AUTH_LDAP_BIND_PASSWORD = 'decide'
AUTH_LDAP_USER_SEARCH = LDAPSearch(
'ou=people,dc=decide,dc=org',
ldap.SCOPE_SUBTREE,
'(uid=%(user)s)',
)

# Populate the Django user from the LDAP directory.
AUTH_LDAP_USER_ATTR_MAP = {
'first_name': 'cn',
'last_name': 'sn',
'email': 'mail',
}

# Keep ModelBackend around for per-user permissions and maybe a local
# superuser.

AUTHENTICATION_BACKENDS = [
'django_auth_ldap.backend.LDAPBackend',
'django.contrib.auth.backends.ModelBackend',
]

0 comments on commit b9e15f9

Please sign in to comment.