示例#1
0
def login(request, response):
    form = AuthenticationForm(request.REQUEST)
    if form.is_valid():
        user = form.get_user()
        _login(request, user)
        if form.cleaned_data["remberme"]:
            store_login_cookie(response, user)
    else:
        assert AjaxError(form.errors)
示例#2
0
def login(request, response):
    form = AuthenticationForm(request.REQUEST)
    if form.is_valid():
        user = form.get_user()
        _login(request, user)
        if form.cleaned_data['remberme']:
            store_login_cookie(response, user)
    else:
        assert AjaxError(form.errors)
示例#3
0
def login(request):
    if request.is_post():
        form = AuthenticationForm(request.POST)
        if form.is_valid():
            user = form.get_user()
            next = request.REQUEST.get('next', reverse('account:index'))
            _login(request, user)
            resp = HttpResponseRedirect(next)
            if form.cleaned_data['remberme']:
                store_login_cookie(resp, user)
            return resp
    else:
        form = AuthenticationForm()
    return 'account/login.html', locals()
示例#4
0
def login(request):
    if request.is_post():
        form = AuthenticationForm(request.POST)
        if form.is_valid():
            user = form.get_user()
            next = request.REQUEST.get("next", reverse("account:index"))
            _login(request, user)
            resp = HttpResponseRedirect(next)
            if form.cleaned_data["remberme"]:
                store_login_cookie(resp, user)
            return resp
    else:
        form = AuthenticationForm()
    return "account/login.html", locals()
示例#5
0
def register(request):
    if request.user.is_authenticated():
        return 'account/registered.html', locals()

    if request.is_post():
        captcha = CaptchaForm(request.session, data=request.POST)
        form = RegisterForm(request.POST)
        if captcha.is_valid() and form.is_valid():
            user = form.save()
            _login(request, user)
            return 'account/register_done.html', locals()
    else:
        captcha = CaptchaForm(request.session)
        form = RegisterForm()
    return 'account/register.html', locals()
示例#6
0
def register(request):
    if request.user.is_authenticated():
        return "account/registered.html", locals()

    if request.is_post():
        captcha = CaptchaForm(request.session, data=request.POST)
        form = RegisterForm(request.POST)
        if captcha.is_valid() and form.is_valid():
            user = form.save()
            _login(request, user)
            return "account/register_done.html", locals()
    else:
        captcha = CaptchaForm(request.session)
        form = RegisterForm()
    return "account/register.html", locals()