Commit 2a329f1c authored by David Seaward's avatar David Seaward Committed by Gogs

Merge branch 'ldap_mail_field_56' of david.seaward/purist_middleware into master

parents f4e3a8a8 4ba946ed
...@@ -14,7 +14,7 @@ class LdapGroupAdmin(admin.ModelAdmin): ...@@ -14,7 +14,7 @@ class LdapGroupAdmin(admin.ModelAdmin):
class LdapPersonAdmin(admin.ModelAdmin): class LdapPersonAdmin(admin.ModelAdmin):
exclude = ['dn', 'objectClass'] exclude = ['dn', 'objectClass']
list_display = ['uid', 'description', ] list_display = ['uid', 'mail', 'description', ]
# #
......
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-02-15 11:33
from __future__ import unicode_literals
import ldapdb.models.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('ldapregister', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='ldapperson',
name='mail',
# field=ldapdb.models.fields.CharField(db_column='mail', default='none', max_length=200),
field=ldapdb.models.fields.CharField(db_column='mail', max_length=200),
preserve_default=False,
),
]
...@@ -9,7 +9,6 @@ from django.conf import settings ...@@ -9,7 +9,6 @@ from django.conf import settings
from django.db import connections, router from django.db import connections, router
from ldapdb.models.fields import CharField, ListField from ldapdb.models.fields import CharField, ListField
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -56,6 +55,7 @@ class LdapPerson(ldapdb.models.Model): ...@@ -56,6 +55,7 @@ class LdapPerson(ldapdb.models.Model):
cn = CharField(db_column='cn', max_length=200) cn = CharField(db_column='cn', max_length=200)
description = CharField(db_column='description', max_length=200) description = CharField(db_column='description', max_length=200)
sn = CharField(db_column='sn', max_length=200) sn = CharField(db_column='sn', max_length=200)
mail = CharField(db_column='mail', max_length=200)
def __str__(self): def __str__(self):
return self.uid return self.uid
......
...@@ -77,14 +77,14 @@ class User(AbstractUser): ...@@ -77,14 +77,14 @@ class User(AbstractUser):
def create_ldap(self): def create_ldap(self):
username = self.get_username() username = self.get_username()
LdapPerson.objects.create(uid=username, cn=username, sn=username) mail = self.get_identity()
LdapPerson.objects.create(uid=username, cn=username, sn=username, mail=mail)
def set_ldap_password(self, raw_password): def set_ldap_password(self, raw_password):
ldap_person = self.get_ldap() ldap_person = self.get_ldap()
ldap_person.change_password(raw_password) ldap_person.change_password(raw_password)
def get_identity(self): def get_identity(self):
# TODO: associated with https://code.puri.sm/purist/account_web/issues/25
return self.get_username() + "@" + settings.SITE_DOMAIN.lower() return self.get_username() + "@" + settings.SITE_DOMAIN.lower()
def save(self, force_insert=False, force_update=False, using=None, update_fields=None): def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
......
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