use signup view rather than redirecting
This commit is contained in:
parent
dd8701409a
commit
081e11400b
1 changed files with 20 additions and 20 deletions
|
@ -7,24 +7,24 @@ from .forms import SignUpForm
|
|||
from .ldap_funcs import create_user
|
||||
|
||||
|
||||
# def signup(request):
|
||||
# if request.method == 'POST':
|
||||
# form = SignUpForm(request.POST)
|
||||
# if form.is_valid():
|
||||
# username = form.cleaned_data.get('username')
|
||||
# raw_password = form.cleaned_data.get('password1')
|
||||
# first_name = form.cleaned_data.get('first_name')
|
||||
# last_name = form.cleaned_data.get('last_name')
|
||||
# email = form.cleaned_data.get('email')
|
||||
# create_user(username, raw_password, first_name, last_name, email)
|
||||
# form.save()
|
||||
# user = authenticate(username=username, password=raw_password)
|
||||
# login(request, user, backend='django_auth_ldap.backend.LDAPBackend')
|
||||
# return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
|
||||
# else:
|
||||
# form = SignUpForm()
|
||||
# return render(request, 'users/signup.html', {'form': form})
|
||||
|
||||
|
||||
def signup(request):
|
||||
return HttpResponseRedirect("https://account.ungleich.ch/register/")
|
||||
if request.method == 'POST':
|
||||
form = SignUpForm(request.POST)
|
||||
if form.is_valid():
|
||||
username = form.cleaned_data.get('username')
|
||||
raw_password = form.cleaned_data.get('password1')
|
||||
first_name = form.cleaned_data.get('first_name')
|
||||
last_name = form.cleaned_data.get('last_name')
|
||||
email = form.cleaned_data.get('email')
|
||||
create_user(username, raw_password, first_name, last_name, email)
|
||||
form.save()
|
||||
user = authenticate(username=username, password=raw_password)
|
||||
login(request, user, backend='django_auth_ldap.backend.LDAPBackend')
|
||||
return HttpResponseRedirect(settings.LOGIN_REDIRECT_URL)
|
||||
else:
|
||||
form = SignUpForm()
|
||||
return render(request, 'users/signup.html', {'form': form})
|
||||
|
||||
|
||||
# def signup(request):
|
||||
# return HttpResponseRedirect("https://account.ungleich.ch/register/")
|
||||
|
|
Loading…
Reference in a new issue