Esempio n. 1
0
def spotify_logout(request):
    assert isinstance(request, HttpRequest)

    response = HttpResponseRedirect("/")
    response.delete_cookie("SpotifyToken")

    return response
Esempio n. 2
0
def user_logout(request):
    logout(request)
    res = HttpResponseRedirect("/")
    res.delete_cookie("user_id")
    res.delete_cookie("date_login")
    messages.success(request, "Successfully Logged Out")
    return res
Esempio n. 3
0
def login(req):
    flag = req.COOKIES.get('flag', '')
    if req.method == 'POST':
        form = UserForm(req.POST, req.FILES)
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            users = User.objects.filter(username=username, password=password)
            if users:
                response = HttpResponseRedirect('../index/')
                response.set_cookie('username', username, 3600)
                return response
            else:
                response = HttpResponseRedirect('../login/')
                response.delete_cookie('flag')
                response.set_cookie('flag', True, 3600)
                return response
    else:
        form = UserForm()
    print 'flag=' + flag
    if flag == 'True':
        print 'here if'
        response = render_to_response('login.html', {
            'title': '登录',
            'form': form,
            'flag': flag
        })
        response.delete_cookie('flag')
        response.set_cookie('flag', False, 3600)
        return response
    else:
        print 'here else'
        return render_to_response('login.html', {'title': '登录', 'form': form})
Esempio n. 4
0
def logout(request):

    re = HttpResponseRedirect(reverse(list))
    # 清理cookie里保存uid

    re.delete_cookie('uid')

    return re
Esempio n. 5
0
def logout_views(request):
    resp = HttpResponseRedirect('/')
    if 'uid' in request.COOKIES:
        resp.delete_cookie('uid')
        resp.delete_cookie('uphone')
    if 'uid' in request.session:
        del request.session['uid']
        del request.session['uphone']
    return resp
Esempio n. 6
0
def car_filter_reset(request):
    if request.POST:
        response = HttpResponseRedirect('/car/list/')

        for cookie in request.COOKIES:
            if str('filter') in cookie:
                response.delete_cookie(cookie)
        return response
    else:
        return HttpResponseRedirect('/car/list/')
Esempio n. 7
0
def logout(request):
    if request.method == 'POST':
        data = {
            'msg': '请求成功',
            'code': '200'
        }
        response = HttpResponseRedirect('/index/index/')
        response.delete_cookie('ticket')
        ticket = request.COOKIES.get('ticket')
        UserTicket.objects.filter(ticket=ticket).delete()

        return JsonResponse(data)
Esempio n. 8
0
def logout(request):

    # Get the auth_token cookie, if it exists.
    auth_cookie = request.COOKIES.get('auth_token')

    # Forward user to index page.
    next_page = reverse('index')
    www_response = HttpResponseRedirect(next_page)

    # Did the auth_cookie actually exist?
    if auth_cookie:
        # If so, log them out in the database and delete their cookie.
        ux_response = _user_logout_ux(auth_cookie)
        www_response.delete_cookie('auth_token')

    return www_response
Esempio n. 9
0
def regist(req):
    tag = True
    if req.method == 'POST':
        form = UserForm(req.POST, req.FILES)
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            User.objects.create(username=username, password=password)
            response = HttpResponseRedirect('../login/')
            response.delete_cookie('flag')
            response.set_cookie('flag', False, 3600)
            return response
    else:
        form = UserForm()
    return render_to_response('register.html', {
        'title': '注册',
        'form': form,
        'tag': tag
    })
Esempio n. 10
0
 def _wrapped_view(view_object, *args, **kwargs):
     try:
         if test_func(view_object.user, *args, **kwargs):
             return view_func(view_object, *args, **kwargs)
         else:
             return redirect(
                 get_redirect_url('/error',
                                  request=view_object.request))
     except PermissionDenied as e:
         if e.redirect_url is not None:
             request = view_object.request
             return login_redirect(request)
         else:
             return JsonResponse({"reason": e.error}, status=403)
     except UrlParseError as e:
         if e.code == 403:
             response = HttpResponseRedirect(settings.LOGIN_URL)
             response.delete_cookie('tenant_name')
             return response
         return JsonResponse({"reason": e.error}, status=e.code)
Esempio n. 11
0
    def process_response(self, request, response):
        """
        Set compact P3P policies and save auth token to cookie.

        P3P is a WC3 standard (see http://www.w3.org/TR/P3P/), and although largely ignored by most
        browsers it is considered by IE before accepting third-party cookies (ie. cookies set by
        documents in iframes). If they are not set correctly, IE will not set these cookies.
        """
        if hasattr(request, "facebook") and request.facebook and request.facebook.oauth_token:
            if "code" in request.REQUEST:
                """ Remove auth related query params """
                path = get_full_path(request, remove_querystrings=['code', 'web_canvas'])
                response = HttpResponseRedirect(path)

            response.set_cookie('facebook_oauth_token', request.facebook.oauth_token.token)
        else:
            response.delete_cookie('facebook_oauth_token')

        response['P3P'] = 'CP="IDC CURa ADMa OUR IND PHY ONL COM STA"'

        return response
Esempio n. 12
0
    def post(self, request):
        username = request.POST.get("username")
        password = request.POST.get("pwd")
        remember = request.POST.get("remember")
        if not all([username, password]):
            return render(request, 'login.html', {'errmsg': '信息填写不完整'})
        try:
            user = User.objects.get(username=username)
        except:
            return render(request, 'login.html', {'errmsg': '查无此用户'})
        if password != user.password:
            return render(request, 'login.html', {'errmsg': '密码错误'})
        request.session["user_id"] = user.id
        next_url = request.GET.get("next_url")
        if next_url is None:
            response = redirect(reverse("goods:index"))
        else:
            response = HttpResponseRedirect(next_url)
        if remember == 'on':
            response.set_cookie('username', username, max_age=30 * 24 * 3600)
        else:
            response.delete_cookie('username')

        return response
Esempio n. 13
0
def car_filter_set(request):
    if request.POST:
        vin_code = request.POST.get('car_vin', None)
        car_date = request.POST.get('car_date', None)
        car_for_loan = request.POST.get('car_for_loan', None)

        response = HttpResponseRedirect('/car/list/')

        if vin_code is not None:
            try:
                response.set_cookie('filter_vin_code', vin_code)
            except:
                pass
        else:
            try:
                response.delete_cookie('filter_vin_code', None, -1000)
            except:
                pass

        if car_date is not None:
            try:
                response.set_cookie('filter_car_date', car_date)
            except:
                pass
        else:
            try:
                response.delete_cookie('filter_car_date', None, -1000)
            except:
                pass

        if car_for_loan is not None:
            try:
                response.set_cookie('filter_car_for_loan', car_for_loan)
            except:
                pass
        else:
            try:
                response.delete_cookie('filter_car_for_loan', None, -1000)
            except:
                pass
        return response
    else:
        return HttpResponseRedirect('/car/list/')
Esempio n. 14
0
def logout(request):
    response = HttpResponseRedirect('/home/')
    response.delete_cookie('user-trade')
    if 'email' in request.session:
        del request.session['email']
    return response
Esempio n. 15
0
def logout(req):
	response = HttpResponseRedirect('/login/')
	response.delete_cookie('username')
	return response
Esempio n. 16
0
def logout(req):
    response = HttpResponseRedirect("/")
    response.delete_cookie("username", "/")
    response.delete_cookie("userid", "/")
    return response