From 2fc4c138b37b194731f59756904d146e11055521 Mon Sep 17 00:00:00 2001 From: Sjoerd Langkemper Date: Tue, 10 Nov 2015 11:29:05 +0100 Subject: [PATCH] Make (user, client) unique on UserConsent We assume this combination is unique with our get and get_or_create calls. --- .../migrations/0006_unique_user_client.py | 18 ++++++++++++++++++ oidc_provider/models.py | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 oidc_provider/migrations/0006_unique_user_client.py diff --git a/oidc_provider/migrations/0006_unique_user_client.py b/oidc_provider/migrations/0006_unique_user_client.py new file mode 100644 index 0000000..1ce586e --- /dev/null +++ b/oidc_provider/migrations/0006_unique_user_client.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('oidc_provider', '0005_token_refresh_token'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='userconsent', + unique_together=set([('user', 'client')]), + ), + ] diff --git a/oidc_provider/models.py b/oidc_provider/models.py index 342e633..b3d4970 100644 --- a/oidc_provider/models.py +++ b/oidc_provider/models.py @@ -89,5 +89,5 @@ class Token(BaseCodeTokenModel): class UserConsent(BaseCodeTokenModel): - - pass + class Meta: + unique_together = ('user', 'client')