core: add uuid to user, use as sub for OpenID
This commit is contained in:
parent
1ab445ab8e
commit
af3df16b90
|
@ -12,7 +12,7 @@ class OpenIDUserInfoView(ScopedResourceMixin, View):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
"""Passbook v1 OpenID API"""
|
"""Passbook v1 OpenID API"""
|
||||||
payload = {
|
payload = {
|
||||||
'sub': request.user.pk,
|
'sub': request.user.uuid.int,
|
||||||
'name': request.user.get_full_name(),
|
'name': request.user.get_full_name(),
|
||||||
'given_name': request.user.first_name,
|
'given_name': request.user.first_name,
|
||||||
'family_name': request.user.last_name,
|
'family_name': request.user.last_name,
|
||||||
|
|
20
passbook/core/migrations/0006_user_uuid.py
Normal file
20
passbook/core/migrations/0006_user_uuid.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 2.1.4 on 2018-12-09 17:58
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('passbook_core', '0005_auto_20181127_1522'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='user',
|
||||||
|
name='uuid',
|
||||||
|
field=models.UUIDField(default=uuid.uuid4, editable=False),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,6 +1,7 @@
|
||||||
"""passbook core models"""
|
"""passbook core models"""
|
||||||
import re
|
import re
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
import reversion
|
import reversion
|
||||||
from django.contrib.auth.models import AbstractUser
|
from django.contrib.auth.models import AbstractUser
|
||||||
|
@ -16,6 +17,7 @@ LOGGER = getLogger(__name__)
|
||||||
class User(AbstractUser):
|
class User(AbstractUser):
|
||||||
"""Custom User model to allow easier adding o f user-based settings"""
|
"""Custom User model to allow easier adding o f user-based settings"""
|
||||||
|
|
||||||
|
uuid = models.UUIDField(default=uuid4, editable=False)
|
||||||
sources = models.ManyToManyField('Source', through='UserSourceConnection')
|
sources = models.ManyToManyField('Source', through='UserSourceConnection')
|
||||||
applications = models.ManyToManyField('Application')
|
applications = models.ManyToManyField('Application')
|
||||||
|
|
||||||
|
|
Reference in a new issue