Commit 081e1140 authored by Aatish Neupane's avatar Aatish Neupane

use signup view rather than redirecting

parent dd870140
......@@ -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):
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/")
# def signup(request):
# return HttpResponseRedirect("https://account.ungleich.ch/register/")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment