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
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
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'}))
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 })
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
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)
def logout(request): # 登出 user_logout(request) massage = '您已经退出!' back = 'login/' return render_to_response('redirect.html', { 'massage': massage, 'back': back })
def logout(request): """ Logout :param request: :return: """ user_logout(request) return redirect("/")
def logout(request): """ 用户登出 :param request: :return: """ user_logout(request) return redirect('/users/login/')
def logout(request): try: del request.session['user'] except KeyError: pass finally: user_logout(request) return HttpResponse(json.dumps({'status': 'success'}))
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')
def logout(request): Count=count.objects.get(id="1") Count.value=Count.value-1 Count.save() user_logout(request) print("logout") return HttpResponseRedirect("/login/")
def logout(request): """ 用户注销 :param request: :return: """ user_logout(request) return JsonResponse({'msg': '注销成功'})
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/")
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')
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")
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))
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
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
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})
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, })
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": "抱歉,登录失败"})
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})
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})
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
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
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
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
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
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
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
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)
def logout(request): user = user_logout(request) url_source = request.META['HTTP_REFERER'] return redirect(url_source)
def logout(request): user_logout(request) messages.success(request, "Successfully logged out.") return redirect(request.REQUEST.get('next', reverse('home')))
def get(self, request, *args, **kwargs): user_logout(request) return super(UserLogoutView, self).get(request, *args, **kwargs)
def logout(request): user_logout(request) return render(request, 'account/logout.html')
def logout(request): user_logout(request) return redirect('/')
def logout(request): user_logout(request) return HttpResponseRedirect(reverse('webapp:index'))
def logout(request): user_logout(request) return redirect(reverse('login'))
def logout(request): user_logout(request) return HttpResponseRedirect('/recipelist')
def logout(request): user_logout(request) redirect_url = request.GET.get("next", "/") return redirect(redirect_url)
def logout(request): if request.user.is_authenticated(): HttpResponseRedirect("/") user_logout(request) return HttpResponseRedirect("/")
def logout(request): try: user_logout(request) return HttpResponse(True) except: return HttpResponse(False)
def logout(req): user_logout(req) return HttpResponseRedirect('/')
def Logout(request): user_logout(request) return redirect('/')
def loginout(request): user_logout(request) # Redirect to a success page. return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
def logout(request): user_logout(request) return redirect('index')
def thread_logout(request): time.sleep(60) user_logout(request)
def logout(request): user_logout(request) return render_to_response('login.html')
def logout(request): user_logout(request) return HttpResponseRedirect(reverse("loginview"))
def logout(request): if request.user.is_authenticated: user_logout(request) return render(request, 'accounts/logout.html')
def logout_web_site(request): user_logout(request) return 1
def logout(request): user_logout(request); return HttpResponseRedirect("/user/login");
def logout(request): user_logout(request) return redirect('posts:index')
def teacher_logout(request): user = request.user #print 'user is : ',user.username user_logout(request) return HttpResponseRedirect(reverse('teacher_login'))
def logout(request): if request.user.is_authenticated(): user_logout(request) return redirect("/")
def logout(request): user_logout(request) return redirect('/accounts/login')