Nameko related changes
This commit is contained in:
parent
a3dca06c35
commit
aec394fc20
4 changed files with 20 additions and 16 deletions
22
dal/urls.py
22
dal/urls.py
|
@ -1,5 +1,5 @@
|
|||
# The different URLs this service does use
|
||||
from django.urls import path
|
||||
#from django.conf.urls import url
|
||||
from django.conf.urls import url
|
||||
from django.contrib import admin
|
||||
|
||||
|
@ -7,14 +7,14 @@ from django.contrib import admin
|
|||
from .views import Register, ChangeData, ChangePassword, ResetPassword, DeleteAccount, Index, LogOut, ResetRequest
|
||||
|
||||
urlpatterns = [
|
||||
path('register/', Register.as_view(), name="register"),
|
||||
path('changedata/', ChangeData.as_view(), name="change_data"),
|
||||
path('resetpassword/', ResetPassword.as_view(), name="reset_password"),
|
||||
path('changepassword/', ChangePassword.as_view(), name="change_password"),
|
||||
path('deleteaccount/', DeleteAccount.as_view(), name="account_delete"),
|
||||
path('index/', Index.as_view(), name="index"),
|
||||
path('logout/', LogOut.as_view(), name="logout"),
|
||||
path('reset/<str:user>/<str:token>/', ResetRequest.as_view()),
|
||||
path('reset/', ResetRequest.as_view(), name="reset"),
|
||||
path('', Index.as_view(), name="index"),
|
||||
url('register/', Register.as_view(), name="register"),
|
||||
url('changedata/', ChangeData.as_view(), name="change_data"),
|
||||
url('resetpassword/', ResetPassword.as_view(), name="reset_password"),
|
||||
url('changepassword/', ChangePassword.as_view(), name="change_password"),
|
||||
url('deleteaccount/', DeleteAccount.as_view(), name="account_delete"),
|
||||
url('index/', Index.as_view(), name="index"),
|
||||
url('logout/', LogOut.as_view(), name="logout"),
|
||||
url('reset/<str:user>/<str:token>/', ResetRequest.as_view()),
|
||||
url('reset/', ResetRequest.as_view(), name="reset"),
|
||||
url('', Index.as_view(), name="index"),
|
||||
]
|
|
@ -10,6 +10,7 @@ from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
|||
from django.core.mail import EmailMessage
|
||||
from .models import ResetToken
|
||||
from .forms import LoginForm
|
||||
from django_nameko import get_pool
|
||||
|
||||
# Imports for the extra stuff not in django
|
||||
|
||||
|
@ -224,11 +225,12 @@ class ResetPassword(View):
|
|||
return render(request, 'resetpassword.html')
|
||||
|
||||
def post(self, request):
|
||||
l = LDAP()
|
||||
urlname = 'reset_password'
|
||||
service = 'send a password reset request'
|
||||
user = request.POST.get('user')
|
||||
# First, check if the user exists
|
||||
if not check_user_exists(user):
|
||||
if not l.check_user_exists(user):
|
||||
return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'The user does not exist.' } )
|
||||
# user exists, so try to get email
|
||||
with get_pool().next() as rpc:
|
||||
|
@ -250,7 +252,7 @@ class ResetPassword(View):
|
|||
# getting epoch for the time now in UTC to spare us headache with timezones
|
||||
creationtime = int(datetime.utcnow().timestamp())
|
||||
# Construct the data for the email
|
||||
email_from = 'Userservice at ungleich <%s>' % config['EMAIL']['EMAILFROM']
|
||||
email_from = 'Userservice at ungleich <%s>' % 'support@ungleich.ch'
|
||||
to = ['%s <%s>' % (user, email)]
|
||||
subject = 'Password reset request for %s' % user
|
||||
link = self.build_reset_link(user, creationtime)
|
||||
|
@ -421,13 +423,14 @@ class DeleteAccount(View):
|
|||
|
||||
# Reads the filled out form
|
||||
def post(self, request):
|
||||
l = LDAP()
|
||||
# Variables for error page
|
||||
urlname = 'account_delete'
|
||||
service = 'delete an account'
|
||||
|
||||
# Does the user exist?
|
||||
username = request.POST.get('username')
|
||||
if not check_user_exists(username):
|
||||
if not l.check_user_exists(username):
|
||||
return render(request, 'error.html', { 'urlname': urlname, 'service': service, 'error': 'Unknown user.' } )
|
||||
|
||||
# Do user and password match?
|
||||
|
|
|
@ -346,5 +346,5 @@ class Log(object):
|
|||
def event_handler_ldap(self, payload):
|
||||
f = open(self.ldaplog, mode='a', encoding='utf-8')
|
||||
f.write(payload)
|
||||
f.close
|
||||
f.close()
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
django
|
||||
django==1.11.20
|
||||
django-auth-ldap
|
||||
python-ldap
|
||||
django-bootstrap3
|
||||
django-filter==2.1.0
|
||||
python-decouple
|
||||
git+https://github.com/pcoder/django-nameko.git#egg=django-nameko
|
Loading…
Reference in a new issue