示例#1
0
def logout(request):
    '''
    View function to handle loggin out users
    '''
    user_logout(request)
    # messages.error(request, 'Successfully logged-Out. Please come back again!')
    return redirect('fleet:index')
def logout(request):
    response = Response()
    user_logout(request)  # 用户退出登录
    delete_login_session(request)
    http_response = HttpResponse(json.dumps(response.__dict__))
    http_response.delete_cookie(COOKIE_NAME)
    return http_response
示例#3
0
 def get_context_data(self, **kwargs):
     context = super(PostView, self).get_context_data(**kwargs)
     if self.request.method == 'GET':
         ###process login form
         login_username = self.request.GET.get("login_username")
         login_password = self.request.GET.get("login_password")
         if login_username and login_password:
             user = authenticate(username=login_username, password=login_password)
             if user is not None:
                 if user.is_active:
                     user_login(self.request, user)
                     context['username_authed'] = login_username
         ###process logout form
         if "logout" in self.request.GET:
             user_logout(self.request)
         context['form_post'] = PostModelForm()
         
     if self.request.method == 'POST':
         form_post = PostModelForm(self.request.POST, self.request.FILES)
         if form_post.is_valid():
             temp = form_post.save(commit=False)
             temp.seller = self.request.user
             temp.save()
         else:
             print(form_post.errors)
             context['form_post'] = form_post
     return context
示例#4
0
def student_logout(request):
	if request.method == 'POST':
		user = request.user
		user_logout(request)
		return HttpResponse(json.dumps({'result':True,'message':'logout successfully'}))
	else :
		return HttpResponse(json.dumps({'result':False,'message':'wrong method'})) 
示例#5
0
def member_change_password(request):
    borrow_book_list, book_amount = all_borrow_books(request)
    information_len = information_amount(request)

    error = ''
    if request.method == 'POST':
        new_password_1 = request.POST.get('new_password_1')
        new_password_2 = request.POST.get('new_password_2')
        email_code = request.POST.get('email_code', '')
        if email_code != '':
            if new_password_1 == new_password_2 and email_code == request.session.get(
                    'email_code', ''):
                user = request.user
                user.set_password(new_password_1)
                user.save()
                user_logout(request)
                return redirect(reverse('user:login'))
            error = '两次密码不一致!'
        else:
            error = '验证码错误!!'
    return render(
        request, 'huiyuan/huiyuan_change_password.html', {
            'book_amount': book_amount,
            'error': error,
            'information_len': information_len
        })
示例#6
0
 def get_context_data(self, **kwargs):
     context = super(PostView, self).get_context_data(**kwargs)
     if self.request.method == 'GET':
         ###process login form
         login_username = self.request.GET.get("login_username")
         login_password = self.request.GET.get("login_password")
         if login_username and login_password:
             user = authenticate(username=login_username, password=login_password)
             if user is not None:
                 if user.is_active:
                     user_login(self.request, user)
                     context['username_authed'] = login_username
         ###process logout form
         if "logout" in self.request.GET:
             user_logout(self.request)
         context['form_post'] = PostForm()
         
     ###process register form
     if self.request.method == 'POST':
         print(self.request.POST)
         form_post = PostForm(self.request.POST)
         print(form_post)
         if form_post.is_valid():
             print(form_post)
             seller_business = SellerBusiness.objects.create()
             seller_business.title = form_post.cleaned_data['title']
             seller_business.content = form_post.cleaned_data['content']
             seller_business.save()
             context['form_post'] = form_post
         else:
             print(form_post)
             context['form_post'] = form_post
         
     return context
示例#7
0
    def get_context_data(self, **kwargs):
        context = super(PostView, self).get_context_data(**kwargs)
        if self.request.method == 'GET':
            ###process login form
            login_username = self.request.GET.get("login_username")
            login_password = self.request.GET.get("login_password")
            if login_username and login_password:
                user = authenticate(username=login_username,
                                    password=login_password)
                if user is not None:
                    if user.is_active:
                        user_login(self.request, user)
                        context['username_authed'] = login_username
            ###process logout form
            if "logout" in self.request.GET:
                user_logout(self.request)
            context['form_post'] = PostModelForm()

        if self.request.method == 'POST':
            form_post = PostModelForm(self.request.POST, self.request.FILES)
            if form_post.is_valid():
                temp = form_post.save(commit=False)
                temp.seller = self.request.user
                temp.save()
            else:
                print(form_post.errors)
                context['form_post'] = form_post
        return context
示例#8
0
    def post(self, request):
        user_logout(request)
        auth = get_authorization_header(request).split()
        token = auth[1].decode()
        tokenObject = Token.objects.select_related('user').get(key=token)
        tokenObject.delete()

        return JsonResponse({'message': 'Logout Successfully!'}, status=200)
示例#9
0
文件: views.py 项目: CarrieSheep/demo
def logout(request):  # 登出
    user_logout(request)
    massage = '您已经退出!'
    back = 'login/'
    return render_to_response('redirect.html', {
        'massage': massage,
        'back': back
    })
示例#10
0
def logout(request):
    """
    Logout
    :param request:
    :return:
    """
    user_logout(request)
    return redirect("/")
示例#11
0
def logout(request):
    """
    用户登出
    :param request:
    :return:
    """
    user_logout(request)
    return redirect('/users/login/')
示例#12
0
def logout(request):
    try:
        del request.session['user']
    except KeyError:
        pass
    finally:
        user_logout(request)

    return HttpResponse(json.dumps({'status': 'success'}))
示例#13
0
def logout(request):
  pdb.set_trace()
  instance = User.objects.get(username=request.user)
  token = Token.objects.get(user=instance)
  if token:
      token.delete()
  Token.objects.create(user=instance)
  user_logout(request)
  return HttpResponseRedirect('/users/login')
示例#14
0
文件: login.py 项目: nblintao/jwb
def logout(request):
    Count=count.objects.get(id="1")
    Count.value=Count.value-1
    Count.save()

    user_logout(request)

    print("logout")
    return HttpResponseRedirect("/login/")
示例#15
0
def logout(request):
    """
    用户注销
    :param request:
    :return:
    """
    user_logout(request)

    return JsonResponse({'msg': '注销成功'})
示例#16
0
文件: login.py 项目: nblintao/jwb
def forcelogout(request):
    Count=count.objects.get(id="1")
    Count.value=Count.value-1
    Count.save()

    timeminus =time.mktime(datetime.now().timetuple()) - time.mktime(request.user.last_login.timetuple())-28800
    if(timeminus>3600):
        user_logout(request)
        return HttpResponseRedirect("/login/")
示例#17
0
def logout(request):
    """
    Logs a user out even if they are not logged in, and redirects them back home.

    :param request:
    :return: redirect
    """

    user_logout(request)
    return redirect('frontend:home')
示例#18
0
def logout(request):
    """
    Function used to logout the user
    :param request: request received from web server
    :return: logs out the user
    """
    try:
        user_logout(request)
        return HttpResponseRedirect(reverse('home'))
    except Exception as e:
        return HttpResponse("something went wrong")
示例#19
0
def logout(req, template_name="rapidsms/loggedout.html"):
    if getattr(settings, 'ENABLE_AUDITLOG', False):
        try:
            from auditlog.utils import audit_log
            log_dict = {'request': req, 'logtype': 'system', 'action':'logout',
                        'detail':'User logged out %s:%s' % (req.user.id, req.user.username) }
            audit_log(log_dict)
        except ImportError:
            pass
    from django.contrib.auth import logout as user_logout
    user_logout(req)
    return render_to_response(template_name, locals(), context_instance=RequestContext(req))
示例#20
0
文件: views.py 项目: njqaaa/deploy
def logout(request):
    from django.contrib.auth import authenticate, logout as user_logout
    user_logout(request)
    auth.logout(request)
    ref = 'http://home.corp.anjuke.com'
    url_get = '%s/logout.php?client_id=%s&client_secret=%s&refer_url=%s' % (oauth_url,client_id,client_secret,ref)
    req = urllib2.Request(url_get)
    try:
        response = urllib2.urlopen(req)
    except HTTPError,e:
        print e
        return None
示例#21
0
def logout(request):
    from django.contrib.auth import authenticate, logout as user_logout
    user_logout(request)
    auth.logout(request)
    ref = 'http://home.corp.anjuke.com'
    url_get = '%s/logout.php?client_id=%s&client_secret=%s&refer_url=%s' % (
        oauth_url, client_id, client_secret, ref)
    req = urllib2.Request(url_get)
    try:
        response = urllib2.urlopen(req)
    except HTTPError, e:
        print e
        return None
示例#22
0
def archives(request):
    # TODO Move this to a custom wrapper function
    if request.user.__class__ != User:
        user_logout(request)
        return redirect(reverse('terminal:index'))
    _channels = Channel.objects.exclude(archives=None)\
        .select_related('game', 'game__series', 'guild')\
        .prefetch_related('archives').filter(
            Q(archives__users__in=[request.user]) | Q(owner=request.user)
        ).distinct()
    return render(request,
                  'terminal/archives.html',
                  context={'channels': _channels})
示例#23
0
def login(request):
    if request.user.is_authenticated:
        return HttpResponseRedirect('/')
    form = LoginForm(request.POST or None)
    if form.is_valid():
        username = form.cleaned_data['username']
        password = form.cleaned_data['password']
        user = authenticate(request, username=username, password=password)
        if user is not None:
            user_logout(request)
            user_login(request, user)
        return HttpResponseRedirect('/')
    return render(request, 'login.html', {
        'form': form,
    })
示例#24
0
def logout(request):
    """

    Parameters
    ----------
    request

    Returns
    -------

    """
    if request.method == "GET":
        if request.user.is_authenticated:
            user_logout(request)
            return redirect("user:login")
        else:
            return render(request, "user/login.html", {"error": "抱歉,登录失败"})
示例#25
0
 def post(self, request):
     # 验证
     error = {}
     static = True
     username = request.POST.get('username', '')
     password = request.POST.get('password', '')
     user = authenticate(username=username, password=password)
     if not user:
         error['username_error'] = '用户不存在或密码错误'
         static = False
     if user and static:
         # 登录前先退出当前登录用户
         user_logout(request)
         # 登录
         user_login(request, user)
         return redirect(reverse('bookapp:index'))
     return render(request, 'user/login.html', {'error': error})
示例#26
0
def index(request):
    if request.method == "POST":
        if login(request):
            # 判断是那种类型的用户
            if Librarians.objects.filter(username=request.user.username):
                return HttpResponseRedirect('/lib/index/')
            elif Readers.objects.filter(username=request.user.username):
                return HttpResponseRedirect('/rer/index/')
            else:
                # 超级管理员不许登录管理员端和读者端
                user_logout(request)
                return HttpResponseRedirect('/index/')
        else:
            return HttpResponseRedirect('/index/')
    else:
        user_logout(request)
        error_login = get_errorlogin_session(request)
        return render(request, 'lms/login.html', {'error_login':error_login})
示例#27
0
    def get_context_data(self, **kwargs):
        context = super(RegisterView, self).get_context_data(**kwargs)
        if self.request.method == 'GET':
            ###process login form
            login_username = self.request.GET.get("login_username")
            login_password = self.request.GET.get("login_password")
            if login_username and login_password:
                user = authenticate(username=login_username,
                                    password=login_password)
                if user is not None:
                    if user.is_active:
                        user_login(self.request, user)
                        context['username_authed'] = login_username
            ###process logout form
            if "logout" in self.request.GET:
                user_logout(self.request)
            context['form_reg'] = RegisterForm()
            context['registered'] = False

        ###process register form
        if self.request.method == 'POST':
            form_reg = RegisterForm(self.request.POST)
            if form_reg.is_valid():
                user = User.objects.create(
                    username=form_reg.cleaned_data['email'],
                    password=form_reg.cleaned_data['password'],
                    email=form_reg.cleaned_data['email'])
                seller = Seller.objects.create()
                seller.user = user
                seller.address = form_reg.cleaned_data['address']
                seller.description = form_reg.cleaned_data['description']
                user.save()
                seller.save()
                print(form_reg)
                context['registered'] = True
                context['form_reg'] = form_reg
                context['result_msg'] = '注册成功!'
            else:
                print(form_reg)
                context['form_reg'] = form_reg
                context['registered'] = False

        return context
示例#28
0
def login(request):
    # fangz前台伪造post请求
    if request.user.is_authenticated():  
        user_logout(request)
        return False     
    if 'error_login' in request.session:
        del request.session['error_login']
    username = request.POST['username']  
    password = request.POST['password']
    user = authenticate(username=username, password=password)
    if user is not None:  
        if user.is_active:
            user_login(request, user)
        else:  
            request.session['error_login'] = "******"
            return False
    else:  
        request.session['error_login'] = "******"
        return False
    return True
示例#29
0
 def get_context_data(self, **kwargs):
     context = super(BListView, self).get_context_data(**kwargs)
     
     ###process login form
     login_username = self.request.GET.get("login_username")
     login_password = self.request.GET.get("login_password")
     if login_username and login_password:
         user = authenticate(username=login_username, password=login_password)
         if user is not None:
             if user.is_active:
                 user_login(self.request, user)
                 context['username_authed'] = login_username
     ###process logout form
     if "logout" in self.request.GET:
         user_logout(self.request)
     user = self.request.user
     blist = []
     blist = SellerBusiness.objects.filter(seller__username = user.username)
     context['blist'] = blist
     return context
示例#30
0
 def get_context_data(self, **kwargs):
     context = super(HomeView, self).get_context_data(**kwargs)
     
     ###process login form
     login_username = self.request.GET.get("login_username")
     login_password = self.request.GET.get("login_password")
     if login_username and login_password:
         login_username = login_username.replace('%40','@')
         print(login_username, login_password)
         user = authenticate(username=login_username, password=login_password)
         if user is not None:
             print(user)
             if user.is_active:
                 print(user)
                 user_login(self.request, user)
                 context['username_authed'] = login_username
     ###process logout form
     if "logout" in self.request.GET:
         user_logout(self.request)
     return context
示例#31
0
 def get_context_data(self, **kwargs):
     context = super(RegisterView, self).get_context_data(**kwargs)
     if self.request.method == 'GET':
         ###process login form
         login_username = self.request.GET.get("login_username")
         login_password = self.request.GET.get("login_password")
         if login_username and login_password:
             user = authenticate(username=login_username, password=login_password)
             if user is not None:
                 if user.is_active:
                     user_login(self.request, user)
                     context['username_authed'] = login_username
         ###process logout form
         if "logout" in self.request.GET:
             user_logout(self.request)
         context['form_reg'] = RegisterForm()
         context['registered'] = False
         
     ###process register form
     if self.request.method == 'POST':
         form_reg = RegisterForm(self.request.POST)
         if form_reg.is_valid():
             user = User.objects.create(username = form_reg.cleaned_data['email'],
                                         password = form_reg.cleaned_data['password'],
                                         email = form_reg.cleaned_data['email'])
             seller = Seller.objects.create()
             seller.user = user
             seller.address = form_reg.cleaned_data['address']
             seller.description = form_reg.cleaned_data['description']
             user.save()
             seller.save()
             print(form_reg)
             context['registered'] = True
             context['form_reg'] = form_reg
             context['result_msg'] = '注册成功!'
         else:
             print(form_reg)
             context['form_reg'] = form_reg
             context['registered'] = False
         
     return context
示例#32
0
    def get_context_data(self, **kwargs):
        context = super(BListView, self).get_context_data(**kwargs)

        ###process login form
        login_username = self.request.GET.get("login_username")
        login_password = self.request.GET.get("login_password")
        if login_username and login_password:
            user = authenticate(username=login_username,
                                password=login_password)
            if user is not None:
                if user.is_active:
                    user_login(self.request, user)
                    context['username_authed'] = login_username
        ###process logout form
        if "logout" in self.request.GET:
            user_logout(self.request)
        user = self.request.user
        blist = []
        blist = SellerBusiness.objects.filter(seller__username=user.username)
        context['blist'] = blist
        return context
示例#33
0
    def get_context_data(self, **kwargs):
        context = super(HomeView, self).get_context_data(**kwargs)

        ###process login form
        login_username = self.request.GET.get("login_username")
        login_password = self.request.GET.get("login_password")
        if login_username and login_password:
            login_username = login_username.replace('%40', '@')
            print(login_username, login_password)
            user = authenticate(username=login_username,
                                password=login_password)
            if user is not None:
                print(user)
                if user.is_active:
                    print(user)
                    user_login(self.request, user)
                    context['username_authed'] = login_username
                    context['bpost_count'] = 5
        ###process logout form
        if "logout" in self.request.GET:
            user_logout(self.request)
        return context
示例#34
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        """Forwards unauthenticated requests to the admin page to the CAS
        login URL, as well as calls to django.contrib.auth.views.login and
        logout.
        """
        if view_func == login:
            return cas_login(request, *view_args, **view_kwargs)
        elif view_func == logout:
            return cas_logout(request, *view_args, **view_kwargs)

        if settings.CAS_ADMIN_PREFIX and \
           not request.path.startswith(settings.CAS_ADMIN_PREFIX):

                # Ignore static
                if view_func.__module__.startswith('django.views.static'):
                    return None

                # Log out admins that stray off the admin section
                if getattr(settings, "CAS_ADMIN_VIEWS_RESTRICTED", False):
                    if request.user.is_authenticated():
                        if request.user.is_staff:
                            return user_logout(request)

                return None
        elif not view_func.__module__.startswith('django.contrib.admin.'):
            return None

        if request.user.is_authenticated():
            if request.user.is_staff:
                return None
            else:
                error = ('<h1>Forbidden</h1><p>You do not have staff '
                         'privileges.</p>')
                return HttpResponseForbidden(error)

        # Allow admins to log in by other means
        elif getattr(settings, 'CAS_ADMIN_IGNORE', False):
            return None

        params = urlencode({REDIRECT_FIELD_NAME: request.get_full_path()})
        return HttpResponseRedirect(reverse(cas_login) + '?' + params)
示例#35
0
def logout(request):
    user = user_logout(request)
    url_source = request.META['HTTP_REFERER']
    return redirect(url_source)
示例#36
0
文件: views.py 项目: andi103/upTee
def logout(request):
    user_logout(request)
    messages.success(request, "Successfully logged out.")
    return redirect(request.REQUEST.get('next', reverse('home')))
示例#37
0
 def get(self, request, *args, **kwargs):
     user_logout(request)
     return super(UserLogoutView, self).get(request, *args, **kwargs)
示例#38
0
def logout(request):
    user_logout(request)
    return render(request, 'account/logout.html')
示例#39
0
def logout(request):
    user_logout(request)
    return redirect('/')
示例#40
0
def logout(request):
    user_logout(request)
    return HttpResponseRedirect(reverse('webapp:index'))
示例#41
0
def logout(request):
	user_logout(request)
	return redirect(reverse('login'))
示例#42
0
def logout(request):
    user_logout(request)

    return HttpResponseRedirect('/recipelist')
示例#43
0
def logout(request):
    user_logout(request)

    redirect_url = request.GET.get("next", "/")

    return redirect(redirect_url)
示例#44
0
文件: views.py 项目: mtotti5/icsocial
def logout(request):
	if request.user.is_authenticated():
		HttpResponseRedirect("/")
	user_logout(request)
	return HttpResponseRedirect("/")
示例#45
0
文件: views.py 项目: Bicket/Tacnet
def logout(request):
    try:
        user_logout(request)
        return HttpResponse(True)
    except:
        return HttpResponse(False)
示例#46
0
def logout(req):
    user_logout(req)
    return HttpResponseRedirect('/')
示例#47
0
def Logout(request):   
    user_logout(request)   
    return  redirect('/')
示例#48
0
def loginout(request):
    user_logout(request)
    # Redirect to a success page.
    return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
示例#49
0
def logout(request):
    user_logout(request)
    return redirect('index') 
示例#50
0
def thread_logout(request):
    time.sleep(60)
    user_logout(request)
示例#51
0
文件: views.py 项目: haiya512/django
def logout(request):
    user_logout(request)
    return render_to_response('login.html')
示例#52
0
def logout(request):
    user_logout(request)
    return HttpResponseRedirect(reverse("loginview"))
示例#53
0
def logout(request):
    if request.user.is_authenticated:
        user_logout(request)
    return render(request, 'accounts/logout.html')
示例#54
0
文件: views.py 项目: njqaaa/deploy
def logout_web_site(request):
    user_logout(request)
    return 1
示例#55
0
def logout(request):
    user_logout(request);
    return HttpResponseRedirect("/user/login");
示例#56
0
def logout(request):
    user_logout(request)
    return redirect('posts:index')
示例#57
0
def teacher_logout(request):
	user = request.user
	#print 'user is : ',user.username
	user_logout(request)
	return HttpResponseRedirect(reverse('teacher_login'))
示例#58
0
文件: views.py 项目: soon/berfmk
def logout(request):
    if request.user.is_authenticated():
        user_logout(request)
    return redirect("/")
示例#59
0
def logout(request):
    user_logout(request)
    return redirect('/accounts/login')