add multiple API tokens per user, removes old API tokens

This commit is contained in:
vabene1111
2022-08-04 17:24:54 +02:00
parent 9e62d8a3a3
commit 3f77b73a61
12 changed files with 666 additions and 220 deletions

View File

@ -4,6 +4,7 @@ import re
import uuid
from datetime import date, timedelta
import oauth2_provider.models
from PIL import Image
from annoying.fields import AutoOneToOneField
from django.contrib import auth
@ -63,6 +64,13 @@ auth.models.User.add_to_class('get_shopping_share', get_shopping_share)
auth.models.User.add_to_class('get_active_space', get_active_space)
def oauth_token_get_owner(self):
return self.user
oauth2_provider.models.AccessToken.add_to_class('get_owner', oauth_token_get_owner)
def get_model_name(model):
return ('_'.join(re.findall('[A-Z][^A-Z]*', model.__name__))).lower()