Browse Source

Profile.token generated from os.urandom

pull/140/head
Pēteris Caune 7 years ago
parent
commit
0b68393bb0
1 changed files with 3 additions and 4 deletions
  1. +3
    -4
      hc/accounts/models.py

+ 3
- 4
hc/accounts/models.py View File

@ -1,6 +1,5 @@
import base64
from base64 import urlsafe_b64encode
import os
import uuid
from datetime import timedelta
from django.conf import settings
@ -82,7 +81,7 @@ class Profile(models.Model):
return self
def prepare_token(self, salt):
token = str(uuid.uuid4())
token = urlsafe_b64encode(os.urandom(24)).decode("utf-8")
self.token = make_password(token, salt)
self.save()
return token
@ -119,7 +118,7 @@ class Profile(models.Model):
emails.change_email(self.user.email, ctx)
def set_api_key(self):
self.api_key = base64.urlsafe_b64encode(os.urandom(24))
self.api_key = urlsafe_b64encode(os.urandom(24))
self.save()
def checks_from_all_teams(self):


Loading…
Cancel
Save