Пример #1
0
def login(request, template_name='simpleauth/signin.html'):
    """Login the user to the website and redirect back."""
    next = clean_next(request.GET.get('next'))
    
    if request.user.is_authenticated():
        return HttpResponseRedirect(next)
    
    try:
        if request.POST['remember_me'] == 'on':
            # By default keep the user logged in for 3 weeks
            login_duration = getattr(settings, 'LOGIN_DAYS', 21) * 60 * 60 * 24
    except:
        login_duration = 0
    request.session.set_expiry(login_duration)
    return auth_login(request, template_name=template_name,
                      redirect_field_name='next',
                      authentication_form=RememberMeAuthForm)
Пример #2
0
def login(request, template_name="simpleauth/signin.html"):
    """Login the user to the website and redirect back."""
    next = clean_next(request.GET.get("next"))

    if request.user.is_authenticated():
        return HttpResponseRedirect(next)

    try:
        if request.POST["remember_me"] == "on":
            # By default keep the user logged in for 3 weeks
            login_duration = getattr(settings, "LOGIN_DAYS", 21) * 60 * 60 * 24
    except:
        login_duration = 0
    request.session.set_expiry(login_duration)
    return auth_login(
        request, template_name=template_name, redirect_field_name="next", authentication_form=RememberMeAuthForm
    )
Пример #3
0
def logout(request, template_name='simpleauth/logged_out.html'):
    """Logout the user from the website and redirect back."""
    next = clean_next(request.GET.get('next'))
    auth_logout(request, next_page=next, template_name=template_name)
    return HttpResponseRedirect(next)
Пример #4
0
def logout(request, template_name="simpleauth/logged_out.html"):
    """Logout the user from the website and redirect back."""
    next = clean_next(request.GET.get("next"))
    auth_logout(request, next_page=next, template_name=template_name)
    return HttpResponseRedirect(next)