api contact
This commit is contained in:
1 parent
0b56766f96
commit
04d2bc957f
14 files changed
+595
-1
No files matched your search
@@ -0,0 +1,25 @@
|
||||
from django.contrib.auth.hashers import check_password, make_password
|
||||
from django.db import models
|
||||
|
||||
from apps.core.models import SingletonConfiguration
|
||||
|
||||
|
||||
class PhoneContactApiKey(SingletonConfiguration):
|
||||
"""One database-managed credential for the read-only Phone contact feed."""
|
||||
|
||||
key_hash = models.CharField(max_length=128, editable=False)
|
||||
is_active = models.BooleanField(default=True, verbose_name="فعال")
|
||||
updated_at = models.DateTimeField(auto_now=True, verbose_name="آخرین تغییر")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "کلید API مخاطبان Phone"
|
||||
verbose_name_plural = "کلید API مخاطبان Phone"
|
||||
|
||||
def set_key(self, raw_key):
|
||||
self.key_hash = make_password(raw_key)
|
||||
|
||||
def accepts(self, raw_key):
|
||||
return bool(self.is_active and self.key_hash and check_password(raw_key, self.key_hash))
|
||||
|
||||
def __str__(self):
|
||||
return "کلید API مخاطبان Phone"
|
||||
Reference in new issue
Block a user