-# ==================
-# = Authentication =
-# ==================
-
-@cache.never_cache
-def simple_login(request):
- if request.method == "GET":
- #next = request.REQUEST.get('next', '')
- #if next == '':
- form = AuthenticationForm(prefix='login')
- return render_to_response('auth/login.html', locals(),
- context_instance=RequestContext(request))
- #else:
- # return HttpResponseRedirect("/"+next)
-
- elif request.method == "POST":
- form = AuthenticationForm(data=request.POST, prefix='login')
- if form.is_valid():
- auth.login(request, form.get_user())
- url = request.META['HTTP_REFERER'].split("next=")[1]
- url = url.replace("%3F","?").replace("%3D","=")
- return HttpResponseRedirect(url)
-
-
-@require_POST
-@cache.never_cache
-def login(request):
- form = AuthenticationForm(data=request.POST, prefix='login')
- if form.is_valid():
- auth.login(request, form.get_user())
- response_data = {'success': True, 'errors': {}}
- else:
- response_data = {'success': False, 'errors': form.errors}
- return HttpResponse(LazyEncoder(ensure_ascii=False).encode(response_data))
-
-
-@require_POST
-@cache.never_cache
-def register(request):
- registration_form = UserCreationForm(request.POST, prefix='registration')
- if registration_form.is_valid():
- user = registration_form.save()
- user = auth.authenticate(
- username=registration_form.cleaned_data['username'],
- password=registration_form.cleaned_data['password1']
- )
- auth.login(request, user)
- response_data = {'success': True, 'errors': {}}
- else:
- response_data = {'success': False, 'errors': registration_form.errors}
- return HttpResponse(LazyEncoder(ensure_ascii=False).encode(response_data))
-
-
-@cache.never_cache
-def logout_then_redirect(request):
- auth.logout(request)
- return HttpResponseRedirect(urlquote_plus(request.GET.get('next', '/'), safe='/?='))
-
-
-