Create account.register function. It's currently not working because arguments is not validating
This commit is contained in:
parent
58a19c7a41
commit
22da68b953
@ -1,5 +1,5 @@
|
|||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from .forms import SiteUserForm
|
from .forms import SiteUserForm
|
||||||
from django.contrib.auth import login, authenticate
|
from django.contrib.auth import login, authenticate
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ API_ERROR_INVALID_LOGIN = (501, 'invalid login')
|
|||||||
API_ERROR_INVALID_PASSWORD = (502, 'invalid password')
|
API_ERROR_INVALID_PASSWORD = (502, 'invalid password')
|
||||||
API_ERROR_INVALID_TOKEN = (503, 'invalid token')
|
API_ERROR_INVALID_TOKEN = (503, 'invalid token')
|
||||||
|
|
||||||
|
# времненное решение, позже нужно будет заменить на конкретные ошибки
|
||||||
|
API_ERROR_USER_REGISTER = (510, 'user register error')
|
||||||
|
|
||||||
|
|
||||||
def make_error_object(ex: Exception):
|
def make_error_object(ex: Exception):
|
||||||
try:
|
try:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from .api_errors import *
|
from .api_errors import *
|
||||||
from .api_utils import *
|
from .api_utils import *
|
||||||
from .models import *
|
from .models import *
|
||||||
|
from account.forms import UserCreationForm
|
||||||
|
|
||||||
|
|
||||||
def _reqire_access_token(params):
|
def _reqire_access_token(params):
|
||||||
@ -22,7 +23,26 @@ def account_auth(params):
|
|||||||
|
|
||||||
|
|
||||||
def account_register(params):
|
def account_register(params):
|
||||||
pass
|
name = api_get_param_str(params, "name")
|
||||||
|
surname = api_get_param_str(params, "surname")
|
||||||
|
phone = api_get_param_str(params, "phone")
|
||||||
|
email = api_get_param_str(params, "email")
|
||||||
|
password = api_get_param_str(params, "password")
|
||||||
|
|
||||||
|
form = UserCreationForm({
|
||||||
|
"email": email,
|
||||||
|
"phone": phone,
|
||||||
|
"name": name,
|
||||||
|
"surname": surname,
|
||||||
|
"password1": password,
|
||||||
|
"password2": password,
|
||||||
|
})
|
||||||
|
|
||||||
|
form.validate_unique()
|
||||||
|
if form.is_valid():
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise Exception(API_ERROR_MISSING_ARGUMENT)
|
||||||
|
|
||||||
|
|
||||||
def account_get(params):
|
def account_get(params):
|
||||||
|
Reference in New Issue
Block a user