mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 14:52:15 +00:00
Init the API key if it doesnt exist
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
import re
|
import uuid
|
||||||
import unicodedata
|
|
||||||
import logging
|
|
||||||
import types
|
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
@@ -12,6 +9,12 @@ class AuthAPIKey(models.Model):
|
|||||||
active = models.BooleanField(default=True)
|
active = models.BooleanField(default=True)
|
||||||
key = models.CharField("API Key", max_length=200)
|
key = models.CharField("API Key", max_length=200)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if not key or key = '':
|
||||||
|
self.key = uuid.uuid4()
|
||||||
|
|
||||||
|
models.Model.save(self, *args, **kwargs)
|
||||||
|
|
||||||
class AuthAPILog(models.Model):
|
class AuthAPILog(models.Model):
|
||||||
|
|
||||||
access_datetime = models.DateTimeField()
|
access_datetime = models.DateTimeField()
|
||||||
|
|||||||
Reference in New Issue
Block a user