Merge branch '198-secrets' into 'develop'
Resolve "Secrets module is only availble on Python 3.6" Closes #198 See merge request funkwhale/funkwhale!190
This commit is contained in:
commit
f5225d3285
|
@ -1,8 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
|
import binascii
|
||||||
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import secrets
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import AbstractUser
|
from django.contrib.auth.models import AbstractUser
|
||||||
|
@ -14,6 +15,10 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
from funkwhale_api.common import fields
|
from funkwhale_api.common import fields
|
||||||
|
|
||||||
|
|
||||||
|
def get_token():
|
||||||
|
return binascii.b2a_hex(os.urandom(15)).decode('utf-8')
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class User(AbstractUser):
|
class User(AbstractUser):
|
||||||
|
|
||||||
|
@ -58,7 +63,7 @@ class User(AbstractUser):
|
||||||
return self.secret_key
|
return self.secret_key
|
||||||
|
|
||||||
def update_subsonic_api_token(self):
|
def update_subsonic_api_token(self):
|
||||||
self.subsonic_api_token = secrets.token_hex(32)
|
self.subsonic_api_token = get_token()
|
||||||
return self.subsonic_api_token
|
return self.subsonic_api_token
|
||||||
|
|
||||||
def set_password(self, raw_password):
|
def set_password(self, raw_password):
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Removed Python 3.6 dependency (secrets module) (#198)
|
Loading…
Reference in New Issue