mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Init the API key if it doesnt exist
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
import re
|
||||
import unicodedata
|
||||
import logging
|
||||
import types
|
||||
import uuid
|
||||
|
||||
from django.db import models
|
||||
|
||||
@@ -12,6 +9,12 @@ class AuthAPIKey(models.Model):
|
||||
active = models.BooleanField(default=True)
|
||||
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):
|
||||
|
||||
access_datetime = models.DateTimeField()
|
||||
|
||||
Reference in New Issue
Block a user