def login(request): if request.method == 'POST': form = AuthForm(request.POST) if form.is_valid(): try: if request.is_ajax(): user = form.authenticate(request) if not user is None: accesstype = request.session['access_type'] auth.login(request, user) if accesstype == DEFUSER_ACCESS_TYPES[0][0]: return json_result({'success': 1, 'accesstype': accesstype}) else: ts = get_template('theme_select.html') themeselect = ts.render(RequestContext(request)) return json_result({'success': 1, 'accesstype': accesstype, 'themeselect': themeselect}) else: return json_form_error(form) else: return HttpResponseRedirect('/') except Exception, e: return HttpResponse(e) else: return json_form_error(form)