Esempio n. 1
0
def clogin(request):
    next = request.GET.get('next')
    form = UserLoginForm(request.POST or None)

    if request.user.is_authenticated:
        return redirect('home')

    if request.method == 'POST' and form.is_valid():
        form.clean()
        username = form.cleaned_data.get('username')
        password = form.cleaned_data.get('password')
        user = authenticate(username=username, password=password)

        if user is not None:
            login(request, user)
            return redirect('home')

    context.update({
        "TITLE": "Login",
        "form": form,
    })
    # if request.method == 'POST'
    if request.user_agent.device.family == "Roomy Native":
        return render(request, "mobile-native/components/login.html", context)
    else:
        return render(request, "web/components/login.html", context)
Esempio n. 2
0
def modal_auth(request):
    next = request.GET.get('next')
    form = UserLoginForm(request.POST or None)

    if request.method == "POST":
        if form.is_valid():
            form.clean()
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password')
            user = authenticate(username=username, password=password)

            if user is not None:
                login(request, user)
                return redirect(request.META.get('HTTP_REFERER', 'index'))
        else:
            #RETURN ERROR MESSAGE
            return redirect(request.META.get('HTTP_REFERER', 'index'))
    else:
        context.update({
            "TITLE": "Login",
            "form": form,
        })
        if request.user_agent.device.family == "Roomy Native":
            return render(request,
                          "mobile-native/components/modals/authenticate.html",
                          context)
        else:
            return render(request, "web/components/modals/authenticate.html",
                          context)
Esempio n. 3
0
def index(request):
    next = request.GET.get('next')

    if request.user.is_authenticated and OwnerAccount.objects.filter(user_id=request.user).exists():
        return render(request, "components/billing.html")
    else:
        # logout(request)
        form = UserLoginForm(request.POST or None)
        if request.method == 'POST' and form.is_valid():
            form.clean()
            username = form.cleaned_data.get('username')
            password = form.cleaned_data.get('password')
            user = authenticate(username=username, password=password)

            if user is not None:
                login(request, user)
                return redirect(next)
            return HttpResponseRedirect(reverse('admin-index'))

        context = {
            'form': form,
            'title': 'Login',
        }
        return render(request, 'components/admin_login/login.html', context)