link signup to account.ungleich.ch, landing page changes
This commit is contained in:
parent
b6f5fd5882
commit
ed99dad379
7 changed files with 61 additions and 23 deletions
|
@ -4,4 +4,3 @@ ALLOWED_HOSTS=.localhost, .ipv6.work
|
|||
AUTH_LDAP_SERVER_URI=ldap://<ldap_host>
|
||||
AUTH_LDAP_BIND_DN=cn=admin,dc=example,dc=com
|
||||
AUTH_LDAP_BIND_PASSWORD=admin
|
||||
AUTH_LDAP_USER_DN_TEMPLATE=uid=%(user)s,ou=users,dc=example,dc=com
|
|
@ -11,7 +11,9 @@ https://docs.djangoproject.com/en/2.1/ref/settings/
|
|||
"""
|
||||
|
||||
import os
|
||||
import ldap
|
||||
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, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
@ -164,7 +166,13 @@ CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
|||
AUTH_LDAP_SERVER_URI = config('AUTH_LDAP_SERVER_URI')
|
||||
AUTH_LDAP_BIND_DN = config('AUTH_LDAP_BIND_DN')
|
||||
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 = {
|
||||
'first_name': 'givenName',
|
||||
'last_name': 'sn',
|
||||
|
|
|
@ -29,7 +29,7 @@ urlpatterns = [
|
|||
'logout/',
|
||||
auth_views.LogoutView.as_view(),
|
||||
name='logout'),
|
||||
path('signup/', signup),
|
||||
path('signup/', signup, name="signup"),
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include('jobs.urls'))
|
||||
]
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
|
||||
<!-- 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://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU"
|
||||
crossorigin="anonymous">
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -1,9 +1,33 @@
|
|||
{% extends 'base.html' %}
|
||||
{% block body_content %}
|
||||
<div class="pricing-header px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
|
||||
<h1 class="display-4">Latest jobs</h1>
|
||||
<p class="lead"></p>
|
||||
<div class="cards">
|
||||
<div class="card-body">
|
||||
<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>
|
||||
{% comment %}
|
||||
<div class="card-deck mb-3 text-center">
|
||||
{% for job in jobs %}
|
||||
<div class="card mb-4 shadow-sm">
|
||||
|
@ -19,4 +43,5 @@
|
|||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endcomment %}
|
||||
{% endblock %}
|
|
@ -6,4 +6,5 @@
|
|||
{% csrf_token %} {{ form.as_p }}
|
||||
<button type="submit">Login</button>
|
||||
</form>
|
||||
Don't have an account? Sign up <a href="{% url 'signup' %}">here</a>.
|
||||
{% endblock %}
|
|
@ -7,20 +7,24 @@ from .forms import SignUpForm
|
|||
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):
|
||||
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})
|
||||
return HttpResponseRedirect("https://account.ungleich.ch/register/")
|
||||
|
|
Loading…
Reference in a new issue