Commit ed99dad3 authored by Aatish Neupane's avatar Aatish Neupane

link signup to account.ungleich.ch, landing page changes

parent b6f5fd58
...@@ -4,4 +4,3 @@ ALLOWED_HOSTS=.localhost, .ipv6.work ...@@ -4,4 +4,3 @@ ALLOWED_HOSTS=.localhost, .ipv6.work
AUTH_LDAP_SERVER_URI=ldap://<ldap_host> AUTH_LDAP_SERVER_URI=ldap://<ldap_host>
AUTH_LDAP_BIND_DN=cn=admin,dc=example,dc=com AUTH_LDAP_BIND_DN=cn=admin,dc=example,dc=com
AUTH_LDAP_BIND_PASSWORD=admin AUTH_LDAP_BIND_PASSWORD=admin
AUTH_LDAP_USER_DN_TEMPLATE=uid=%(user)s,ou=users,dc=example,dc=com
\ No newline at end of file
...@@ -11,7 +11,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/ ...@@ -11,7 +11,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
""" """
import os import os
import ldap
from decouple import config, Csv from decouple import config, Csv
from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...@@ -164,7 +166,13 @@ CRISPY_TEMPLATE_PACK = 'bootstrap4' ...@@ -164,7 +166,13 @@ CRISPY_TEMPLATE_PACK = 'bootstrap4'
AUTH_LDAP_SERVER_URI = config('AUTH_LDAP_SERVER_URI') AUTH_LDAP_SERVER_URI = config('AUTH_LDAP_SERVER_URI')
AUTH_LDAP_BIND_DN = config('AUTH_LDAP_BIND_DN') AUTH_LDAP_BIND_DN = config('AUTH_LDAP_BIND_DN')
AUTH_LDAP_BIND_PASSWORD = config('AUTH_LDAP_BIND_PASSWORD') AUTH_LDAP_BIND_PASSWORD = config('AUTH_LDAP_BIND_PASSWORD')
AUTH_LDAP_USER_DN_TEMPLATE = config('AUTH_LDAP_USER_DN_TEMPLATE') AUTH_LDAP_USER_SEARCH = LDAPSearchUnion(
LDAPSearch("ou=users,dc=ungleich,dc=ch",
ldap.SCOPE_SUBTREE, "(uid=%(user)s)"),
LDAPSearch("ou=customers,dc=ungleich,dc=ch",
ldap.SCOPE_SUBTREE, "(uid=%(user)s)"),
)
AUTH_LDAP_USER_ATTR_MAP = { AUTH_LDAP_USER_ATTR_MAP = {
'first_name': 'givenName', 'first_name': 'givenName',
'last_name': 'sn', 'last_name': 'sn',
......
...@@ -29,7 +29,7 @@ urlpatterns = [ ...@@ -29,7 +29,7 @@ urlpatterns = [
'logout/', 'logout/',
auth_views.LogoutView.as_view(), auth_views.LogoutView.as_view(),
name='logout'), name='logout'),
path('signup/', signup), path('signup/', signup, name="signup"),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', include('jobs.urls')) path('', include('jobs.urls'))
] ]
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
<!-- Bootstrap CSS --> <!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU"
crossorigin="anonymous">
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>
</head> </head>
<body> <body>
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% block body_content %} {% block body_content %}
<div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center"> <div class="cards">
<h1 class="display-4">Latest jobs</h1> <div class="card-body">
<p class="lead"></p> <div class="row">
<div class="col-12">
<h1 class="h5">Latest Jobs</h1>
</div>
</div>
{% for job in jobs %}
<div class="row">
<div class="col-12 border border-info">
<div>
<a href="{{ job.get_absolute_url }}">{{ job.title }}</a></h4>
</div>
<div>
{% for tag in job.tags.all %}
<i class="fas fa-tag"></i> {{tag}}
{% endfor %}
</div>
<div>
<a href="{% url 'jobs:job_apply' job.pk %}">Apply</a>
</div>
</div>
</div>
{% endfor %}
</div>
</div> </div>
{% comment %}
<div class="card-deck mb-3 text-center"> <div class="card-deck mb-3 text-center">
{% for job in jobs %} {% for job in jobs %}
<div class="card mb-4 shadow-sm"> <div class="card mb-4 shadow-sm">
...@@ -19,4 +43,5 @@ ...@@ -19,4 +43,5 @@
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
{% endcomment %}
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -6,4 +6,5 @@ ...@@ -6,4 +6,5 @@
{% csrf_token %} {{ form.as_p }} {% csrf_token %} {{ form.as_p }}
<button type="submit">Login</button> <button type="submit">Login</button>
</form> </form>
Don't have an account? Sign up <a href="{% url 'signup' %}">here</a>.
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -7,20 +7,24 @@ from .forms import SignUpForm ...@@ -7,20 +7,24 @@ from .forms import SignUpForm
from .ldap_funcs import create_user from .ldap_funcs import create_user
# def signup(request):
# if request.method == 'POST':
# form = SignUpForm(request.POST)
# if form.is_valid():
# username = form.cleaned_data.get('username')
# raw_password = form.cleaned_data.get('password1')
# first_name = form.cleaned_data.get('first_name')
# last_name = form.cleaned_data.get('last_name')
# email = form.cleaned_data.get('email')
# create_user(username, raw_password, first_name, last_name, email)
# form.save()
# user = authenticate(username=username, password=raw_password)
# login(request, user, backend='django_auth_ldap.backend.LDAPBackend')
# return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
# else:
# form = SignUpForm()
# return render(request, 'users/signup.html', {'form': form})
def signup(request): def signup(request):
if request.method == 'POST': return HttpResponseRedirect("https://account.ungleich.ch/register/")
form = SignUpForm(request.POST)
if form.is_valid():
username = form.cleaned_data.get('username')
raw_password = form.cleaned_data.get('password1')
first_name = form.cleaned_data.get('first_name')
last_name = form.cleaned_data.get('last_name')
email = form.cleaned_data.get('email')
create_user(username, raw_password, first_name, last_name, email)
form.save()
user = authenticate(username=username, password=raw_password)
login(request, user, backend='django_auth_ldap.backend.LDAPBackend')
return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
else:
form = SignUpForm()
return render(request, 'users/signup.html', {'form': form})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment