Exemplo n.º 1
0
def login(request):
    context = {
        'username':'',
        'message':None
    }

    if request.method == "POST":
        username = request.POST['username']
        password = request.POST['password']
        user = authenticate(username=username, password=password)
        if user is not None:
            if user.is_active:
                dologin(request, user)
                if request.POST.get('redirect_url', None):
                    return HttpResponseRedirect(request.POST['redirect_url'])
                else:
                    return HttpResponseRedirect(reverse("core_index"))
            else:
                message = "Sorry, your account has been disabled. Please check your e-mail for a password reset e-mail or contact a co-ordinator."
        else:
            message = "Sorry, your username and password were invalid."
        context['username'], context['message'] = username, message
        context['redirect_url'] = request.POST.get('redirect_url', '')
    else:
        context['redirect_url'] = request.GET.get('redirect_url', '')
    

    return mobile_render(request, context, "auth/login")
Exemplo n.º 2
0
def webauth_failure(request):
    """
    Displays a message to say something went wrong with Webauth and sends
    a notification to the admins to let him/her know.
    """
    mail_admins('Webauth failure for mobile_portal', unicode(request)) 
    
    return mobile_render(request, {}, "auth/webauth_failure")
Exemplo n.º 3
0
def logout(request):
    context = {
        'used_webauth':request.session.get('_auth_user_backend') == 'mobile_portal.webauth.backends.WebauthBackend',
    }
    dologout(request)
    return mobile_render(request, context, "auth/logged_out")