Register add
parent
12ed80292b
commit
e88cd4bc59
|
@ -1,5 +1,7 @@
|
|||
FROM python:3.10.0-alpine3.15
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
RUN apk add --update --no-cache\
|
||||
build-base \
|
||||
openldap-dev\
|
||||
|
@ -9,9 +11,6 @@ RUN apk add --update --no-cache\
|
|||
# FIX https://github.com/python-ldap/python-ldap/issues/432
|
||||
RUN echo 'INPUT ( libldap.so )' > /usr/lib/libldap_r.so
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
COPY requirements.txt ./
|
||||
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
COPY ungleichuser/ .
|
||||
|
|
|
@ -4,9 +4,14 @@ This service runs on [account.ungleich.ch](https://account.ungleich.ch/) and
|
|||
allows customers manage their ungleich account (register, edit mail & password,
|
||||
...).
|
||||
|
||||
## v2
|
||||
## Status v2
|
||||
|
||||
* See below ungleichuser/
|
||||
* register view created
|
||||
* Not solved:
|
||||
* email verification *before* user is created
|
||||
* Solved
|
||||
* Finding highest uid, increasing by 1
|
||||
|
||||
## Todos for v2:
|
||||
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
<meta name="description" content="">
|
||||
<meta name="author" content="ungleich glarus ag">
|
||||
|
||||
<title> Ungleich userservice </title>
|
||||
<title> Ungleich User Service </title>
|
||||
|
||||
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="{% static 'datacenterlight/css/bootstrap-3.3.7.min.css' %}" rel="stylesheet">
|
||||
|
||||
<!-- Custom CSS -->
|
||||
<!--<link href=" static 'hosting/css/pricing.css' %}" rel="stylesheet">-->
|
||||
<link href="{% static 'hosting/css/landing-page.css' %}" rel="stylesheet">
|
||||
|
||||
<!-- Custom Fonts -->
|
||||
|
@ -34,19 +33,8 @@
|
|||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
<!-- with 'hosting/img/'|add:hosting|add:'-intro-bg.png' as image_static
|
||||
<style media="screen" type="text/css">
|
||||
.intro-header {
|
||||
background: url(" static image_static %}") no-repeat center center;
|
||||
}
|
||||
</style>
|
||||
-->
|
||||
<!-- endwith %}-->
|
||||
|
||||
<!-- Google analytics -->
|
||||
<!-- include "google_analytics.html" %} -->
|
||||
<!-- End Google Analytics -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
# Debian/Devuanp
|
||||
apt install libldap2-dev libsasl2-dev
|
|
@ -1,6 +1,9 @@
|
|||
django==4.0
|
||||
ldap3
|
||||
|
||||
django-crispy-forms
|
||||
bootstrap4
|
||||
|
||||
#django-auth-ldap
|
||||
|
||||
# To check
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #17a2b8;
|
||||
height: 100vh;
|
||||
}
|
||||
#login .container #login-row #login-column #login-box {
|
||||
margin-top: 120px;
|
||||
max-width: 600px;
|
||||
height: 320px;
|
||||
border: 1px solid #9C9C9C;
|
||||
background-color: #EAEAEA;
|
||||
}
|
||||
#login .container #login-row #login-column #login-box #login-form {
|
||||
padding: 20px;
|
||||
}
|
||||
#login .container #login-row #login-column #login-box #login-form #register-link {
|
||||
margin-top: -85px;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
|
||||
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
|
||||
<!------ Include the above in your HEAD tag ---------->
|
||||
|
||||
<body>
|
||||
<div id="login">
|
||||
<h3 class="text-center text-white pt-5">Login form</h3>
|
||||
<div class="container">
|
||||
<div id="login-row" class="row justify-content-center align-items-center">
|
||||
<div id="login-column" class="col-md-6">
|
||||
<div id="login-box" class="col-md-12">
|
||||
<form id="login-form" class="form" action="" method="post">
|
||||
<h3 class="text-center text-info">Login</h3>
|
||||
<div class="form-group">
|
||||
<label for="username" class="text-info">Username:</label><br>
|
||||
<input type="text" name="username" id="username" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password" class="text-info">Password:</label><br>
|
||||
<input type="text" name="password" id="password" class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="remember-me" class="text-info"><span>Remember me</span> <span><input id="remember-me" name="remember-me" type="checkbox"></span></label><br>
|
||||
<input type="submit" name="submit" class="btn btn-info btn-md" value="submit">
|
||||
</div>
|
||||
<div id="register-link" class="text-right">
|
||||
<a href="#" class="text-info">Register here</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
|
@ -38,6 +38,8 @@ INSTALLED_APPS = [
|
|||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'crispy_forms',
|
||||
'ungleichuser'
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -122,3 +124,5 @@ STATIC_URL = 'static/'
|
|||
# https://docs.djangoproject.com/en/dev/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,18 @@
|
|||
{% extends "ungleichuser/header.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
<!--Register-->
|
||||
<div class="container py-5">
|
||||
<h1>Register</h1>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{{ register_form|crispy }}
|
||||
<button class="btn btn-primary" type="submit">Register</button>
|
||||
</form>
|
||||
<p class="text-center">If you already have an account, <a href="/login">login</a> instead.</p>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -16,8 +16,11 @@ Including another URLconf
|
|||
from django.contrib import admin
|
||||
import django.contrib.auth
|
||||
from django.urls import path, include
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
# path('admin/', admin.site.urls),
|
||||
# path("", views.homepage, name="homepage"),
|
||||
path("register", views.register_request, name="register"),
|
||||
path('accounts/', include('django.contrib.auth.urls')),
|
||||
]
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
from django.shortcuts import render, redirect
|
||||
from .forms import NewUserForm
|
||||
from django.contrib.auth import login
|
||||
from django.contrib import messages
|
||||
|
||||
def register_request(request):
|
||||
if request.method == "POST":
|
||||
form = NewUserForm(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
user = form.save()
|
||||
login(request, user)
|
||||
messages.success(request, "Registration successful." )
|
||||
return redirect("main:homepage")
|
||||
|
||||
messages.error(request, "Unsuccessful registration. Invalid information.")
|
||||
|
||||
form = NewUserForm()
|
||||
return render (request=request,
|
||||
template_name="ungleichuser/register.html",
|
||||
context={"register_form":form})
|
Loading…
Reference in New Issue