コード例 #1
0
ファイル: views.py プロジェクト: gruzilla/NewsBlur
def login(request):
    code = -1
    errors = None
    user_agent = request.environ.get('HTTP_USER_AGENT', '')
    ip = request.META.get('HTTP_X_FORWARDED_FOR',
                          None) or request.META['REMOTE_ADDR']

    if not user_agent or user_agent.lower() in ['nativehost']:
        errors = dict(user_agent="You must set a user agent to login.")
        logging.user(
            request, "~FG~BB~SK~FRBlocked ~FGAPI Login~SN~FW: %s / %s" %
            (user_agent, ip))
    elif request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.errors:
            errors = form.errors
        if form.is_valid():
            login_user(request,
                       form.get_user(),
                       backend='django.contrib.auth.backends.ModelBackend')
            logging.user(
                request,
                "~FG~BB~SKAPI Login~SN~FW: %s / %s" % (user_agent, ip))
            code = 1
    else:
        errors = dict(method="Invalid method. Use POST. You used %s" %
                      request.method)

    return dict(code=code, errors=errors)
コード例 #2
0
ファイル: views.py プロジェクト: tosh/NewsBlur
def login(request):
    if request.method == "POST":
        form = LoginForm(request.POST, prefix='login')
        if form.is_valid():
            login_user(request, form.get_user())
            logging.info(" ---> [%s] Login" % form.get_user())
            return HttpResponseRedirect(reverse('index'))

    return index(request)
コード例 #3
0
def login(request):
    code = -1
    if request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(form.get_user(), "~FG~BB~SKAPI Login~FW")
            code = 1

    return dict(code=code)
コード例 #4
0
ファイル: views.py プロジェクト: adamjernst/NewsBlur
def login(request):
    code = -1
    if request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(form.get_user(), "~FG~BB~SKAPI Login~FW")
            code = 1

    return dict(code=code)
コード例 #5
0
ファイル: views.py プロジェクト: linuxayn/NewsBlur
def login(request):
    form = LoginForm()

    if request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(form.get_user(), "~FG~BBOAuth Login~FW")
            return HttpResponseRedirect(request.POST['next'] or reverse('index'))

    return render_to_response('accounts/login.html', {
        'form': form,
        'next': request.REQUEST.get('next', "")
    }, context_instance=RequestContext(request))
コード例 #6
0
def login(request):
    form = LoginForm()

    if request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(form.get_user(), "~FG~BBOAuth Login~FW")
            return HttpResponseRedirect(request.POST['next'] or reverse('index'))

    return render_to_response('accounts/login.html', {
        'form': form,
        'next': request.REQUEST.get('next', "")
    }, context_instance=RequestContext(request))
コード例 #7
0
ファイル: views.py プロジェクト: saidimu/NewsBlur
def login(request):
    code = -1
    errors = None

    if request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.errors:
            errors = form.errors
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(request, "~FG~BB~SKAPI Login~FW")
            code = 1

    return dict(code=code, errors=errors)
コード例 #8
0
ファイル: views.py プロジェクト: gruzilla/NewsBlur
def login(request):
    form = LoginForm()

    if request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.is_valid():
            login_user(request, form.get_user(), backend='django.contrib.auth.backends.ModelBackend')
            logging.user(form.get_user(), "~FG~BBOAuth Login~FW")
            return HttpResponseRedirect(request.POST['next'] or reverse('index'))

    return render(request, 'accounts/login.html', {
        'form': form,
        'next': request.POST.get('next', "") or request.GET.get('next', "")
    })
コード例 #9
0
ファイル: views.py プロジェクト: jmorahan/NewsBlur
def login(request):
    form = LoginForm()

    if request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(form.get_user(), "~FG~BBOAuth Login~FW")
            return HttpResponseRedirect(request.POST["next"] or reverse("index"))

    return render_to_response(
        "accounts/login.html",
        {"form": form, "next": request.REQUEST.get("next", "")},
        context_instance=RequestContext(request),
    )
コード例 #10
0
ファイル: views.py プロジェクト: thongly/NewsBlur
def login(request):
    code = -1
    errors = None
    
    if request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.errors:
            errors = form.errors
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(request, "~FG~BB~SKAPI Login~FW")
            code = 1
    else:
        errors = dict(method="Invalid method. Use POST. You used %s" % request.method)
        
    return dict(code=code, errors=errors)
コード例 #11
0
def login(request):
    code = -1
    if request.method == "POST":
        form = LoginForm(request.POST, prefix='login')
        if form.is_valid():
            login_user(request, form.get_user())
            if request.POST.get('api'):
                logging.user(form.get_user(), "~FG~BB~SKiPhone Login~FW")
                code = 1
            else:
                logging.user(form.get_user(), "~FG~BBLogin~FW")
                return HttpResponseRedirect(reverse('index'))

    if request.POST.get('api'):
        return HttpResponse(json.encode(dict(code=code)), mimetype='application/json')
    else:
        return index(request)
コード例 #12
0
ファイル: views.py プロジェクト: vvarp/NewsBlur
def login(request):
    code = -1
    if request.method == "POST":
        form = LoginForm(request.POST, prefix="login")
        if form.is_valid():
            login_user(request, form.get_user())
            if request.POST.get("api"):
                logging.info(" ---> [%s] ~FG~BB~SKiPhone Login~FW" % form.get_user())
                code = 1
            else:
                logging.info(" ---> [%s] ~FG~BBLogin~FW" % form.get_user())
                return HttpResponseRedirect(reverse("index"))

    if request.POST.get("api"):
        return HttpResponse(json.encode(dict(code=code)), mimetype="application/json")
    else:
        return index(request)
コード例 #13
0
ファイル: views.py プロジェクト: pabloav/NewsBlur
def login(request):
    code = -1
    errors = None
    user_agent = request.environ.get("HTTP_USER_AGENT", "")

    if not user_agent or user_agent.lower() in ["nativehost"]:
        errors = dict(user_agent="You must set a user agent to login.")
        logging.user(request, "~FG~BB~SK~FRBlocked ~FGAPI Login~SN~FW: %s" % (user_agent))
    elif request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.errors:
            errors = form.errors
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(request, "~FG~BB~SKAPI Login~SN~FW: %s" % user_agent)
            code = 1
    else:
        errors = dict(method="Invalid method. Use POST. You used %s" % request.method)

    return dict(code=code, errors=errors)
コード例 #14
0
ファイル: views.py プロジェクト: angelomendonca/NewsBlur
def login(request):
    code = -1
    errors = None
    user_agent = request.environ.get('HTTP_USER_AGENT', '')

    if not user_agent or user_agent.lower() in ['nativehost']:
        errors = dict(user_agent="You must set a user agent to login.")
        ip = request.META.get('HTTP_X_REAL_IP', None) or request.META['REMOTE_ADDR']
        logging.user(request, "~FG~BB~SK~FRBlocked ~FGAPI Login~SN~FW: %s / %s" % (user_agent, ip))
    elif request.method == "POST":
        form = LoginForm(data=request.POST)
        if form.errors:
            errors = form.errors
        if form.is_valid():
            login_user(request, form.get_user())
            logging.user(request, "~FG~BB~SKAPI Login~SN~FW: %s" % user_agent)
            code = 1
    else:
        errors = dict(method="Invalid method. Use POST. You used %s" % request.method)
        
    return dict(code=code, errors=errors)