root / uauth / organization / utils.py @ 7b499930
1 |
import random |
---|---|
2 |
|
3 |
from django.contrib.auth.hashers import make_password |
4 |
|
5 |
from .models import LocalAccount |
6 |
|
7 |
|
8 |
def create_password(): |
9 |
return ''.join([random.choice('23456789ABCDEFGHJLMNPQRSTUVWXZabcdefghjkmnpqrstuvwxyz') |
10 |
for x in range(random.randint(6,9))]) |
11 |
|
12 |
|
13 |
def create_user(data): |
14 |
if not data['password']: |
15 |
data['password'] = create_password() |
16 |
try: |
17 |
user = LocalAccount.objects.create(**data) |
18 |
return user |
19 |
except: |
20 |
return False |