Help!! Pretty new to software development.
I need to show password_set_date within the user object of my app. Currently, when I
console.log(sessionStorage.getItem(‘user’))
(from the front-end) I get something like this:
{id: id, username: username, first_name: first_name, last_name: last_name, date: date}
I need to add a password_set_date field to this user object
password_set_date is not a column in the postgres DB but is returned from LDAP.
I don’t need to modify the authentication.
models.py
class User(AbstractUser):
created_at = models.DateTimeField(auto_now_add=True, null=True)
modified_at = models.DateTimeField(auto_now=True, null=True)
source = models.IntegerField(default=int(settings.LOCATION_ID))
last_login = models.DateTimeField(blank=True, null=True)
serializers.py
class Meta:
model = User
fields = [
'id',
'username',
'first_name',
'last_name',
'date',
]
ref_name = "SecondUser"
views.py
if results:
res = c.response[0]['attributes']
user = User.objects.get(username=req['username'])
user.first_name = res.get('givenName', '')
user.last_name = res.get('sn', '')
user.email = res.get('mail', '')
(results refers to the LDAP query)
Let me know if you need any additional information/code.
Please help!! Really appreciate it!
What I have tried:
Modifying the models.py AbstractUser model, views.py file & serializers.py file, but I honestly don’t understand them or their relationship.