def logout(request): auth_logout(request) # # !!! CHANGE HOST ADDR (part of) # return HttpResponseRedirect('https://api.tu.ac.th/logout/?next={}'.format( request.META['HTTP_REFERER']))
def spotify_logout(request): if User.objects.filter(username=request.user.username).exists(): spot_user = User.objects.get(username=request.user.username) spot_user.delete() auth_logout(request) return redirect(reverse('spotify_to_gpm_app:index'))
def remote_logout(request): logout_url = urlparse.urljoin(settings.TROJSTEN_LOGIN_PROVIDER_URL, reverse('account_logout')) next_url = request.GET.get('next_page', '/') request.GET = request.GET.copy() auth_logout(request) return redirect('%s?next_page=%s' % (logout_url, quote(request.build_absolute_uri(next_url))))
def logout(request): if request.user.is_authenticated: auth_logout(request) response = HttpResponseRedirect(settings.LOGOUT_REDIRECT_URL) response.delete_cookie('first_name') response.delete_cookie('last_name') response.delete_cookie('email') return response
def auth0_logout(request): # user = request.user logout(request) auth_views.auth_logout(request) return_to = urlencode({'returnTo': request.build_absolute_uri('/')}) logout_url = 'https://%s/v2/logout?client_id=%s&%s' % \ (settings.SOCIAL_AUTH_AUTH0_DOMAIN, settings.SOCIAL_AUTH_AUTH0_KEY, return_to) return HttpResponseRedirect(logout_url)
def close_account(request): user = request.user try: user.is_active = "0" user.save() auth_views.auth_logout(request) return JsonResponse({'results': True}) except: return JsonResponse({'results': False})
def logout(request): next_url = request.GET.get('next_page', '/') response = auth_logout(request, next_page=next_url) messages.success(request, _('Logout successful')) if urlparse.urlparse(next_url).netloc: return redirect(next_url) return response
def logout(request): if (getattr(settings, 'SAML_ENABLED', False) and BACKEND_SESSION_KEY in request.session and request.session[BACKEND_SESSION_KEY] == 'djangosaml2.backends.Saml2Backend'): return saml2_logout(request) else: return auth_logout(request, template_name='registration/logout.html')
def logout(request): """ Respond to a logout request. """ context = {'is_testing' : _is_test_url()} return auth_logout(request, extra_context=context)
def logout(request, user_type="applicant", template_name=None, *args, **kwargs): if request.user.is_authenticated(): if request.method == "GET": return render_to_response(template_name, {}, context_instance=RequestContext(request)) elif request.method == "POST": return auth_logout(request, *args, **kwargs) else: return HttpResponseRedirect(reverse("login"))
def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME, current_app=None, extra_context=None): return auth_logout(request, next_page, template_name, redirect_field_name, current_app, extra_context)
def logout(request, *args, **kwargs): # Save the user who is logging out user = request.user response = auth_logout(request, *args, **kwargs) if hasattr(user, 'aasheuser'): # If this was an AASHE Account logout, delete the Drupal cookie aashe_user = user.aasheuser response = unset_session_id(request, response) return response
def post(self, request, *args, **kwargs): if not self.request.user.is_authenticated(): raise Exception("You are not logged in!") if request.POST.get('logout'): return auth_logout(self.request, template_name=self.template_name, next_page=getattr(self, 'next_page', settings.LOGIN_URL), extra_context=locals() ) return HttpResponseRedirect(reverse('index'))
def logout(request): referrer = request.META.get('HTTP_REFERER') result = urlparse.urlparse(referrer) urlPath = result.path urlQuery = result.query nextParams = ''.join([urlPath, '?', urlQuery]) nextParams = urlquote(nextParams) nextPage = ''.join([LOGIN_URL, '?next=', nextParams]) logger.info('user %s logout.' % request.user.username) return auth_logout(request, next_page=nextPage)
def delete_account_view(request): if not request.user.is_authenticated(): return HttpResponseForbidden() if request.POST: for participant in request.user.participant_set.all(): participant.erase_data() request.user.is_active = False request.user.save() return auth_logout(request, template_name="registration/delete_account_done.html") return TemplateResponse(request, "registration/delete_account_confirmation.html")
def logout(request, next_page=None, template_name='registration/logged_out.html', redirect_field_name=REDIRECT_FIELD_NAME, current_app=None, extra_context=None): return auth_logout( request, next_page, template_name, redirect_field_name, current_app, extra_context )
def delete_account_view(request): if not request.user.is_authenticated: return HttpResponseForbidden() if request.POST: for participant in request.user.participant_set.all(): participant.erase_data() request.user.is_active = False request.user.save() return auth_logout( request, template_name='registration/delete_account_done.html') return TemplateResponse(request, 'registration/delete_account_confirmation.html')
def logout(request): response = auth_logout(request, next_page = 'wagtailadmin_login') # By default, logging out will generate a fresh sessionid cookie. We want to use the # absence of sessionid as an indication that front-end pages are being viewed by a # non-logged-in user and are therefore cacheable, so we forcibly delete the cookie here. response.delete_cookie(settings.SESSION_COOKIE_NAME, domain=settings.SESSION_COOKIE_DOMAIN, path=settings.SESSION_COOKIE_PATH) # HACK: pretend that the session hasn't been modified, so that SessionMiddleware # won't override the above and write a new cookie. request.session.modified = False return response
def logout_user(request): user = request.user if user and hasattr(user, 'social_auth'): social_user = user.social_auth.get(user_id=user.id) if social_user is not None: provider = social_user.provider if provider == 'auth0': auth0_logout(request) elif provider == 'facebook': auth_views.auth_logout(request) elif provider == 'google-oauth2': auth_views.auth_logout(request) else: logout(request) else: logout(request) else: logout(request) return redirect(reverse('quantummanagementapp:landing_page'))
def logout(request): response = auth_logout(request, next_page='student-profiles:login') # By default, logging out will generate a fresh sessionid cookie. We want to use the # absence of sessionid as an indication that front-end pages are being viewed by a # non-logged-in user and are therefore cacheable, so we forcibly delete the cookie here. response.delete_cookie(settings.SESSION_COOKIE_NAME, domain=settings.SESSION_COOKIE_DOMAIN, path=settings.SESSION_COOKIE_PATH) # HACK: pretend that the session hasn't been modified, so that SessionMiddleware # won't override the above and write a new cookie. request.session.modified = False return response
def Logout(oRequest): """ View/Function to logout of the tool, unlocking any record the user still has locked and immediately expiring session :param oRequest: Django HTTP request object :return: Logout via authentication module logout function """ try: Unlock(oRequest, iHeaderPK=oRequest.session.get('existing', None)) except Header.DoesNotExist: pass # end try oRequest.session.set_expiry(1) # S-10576: Change the header of the tool to ACC :- Changed the tool name from pcbm to acc return auth_logout(oRequest, next_page='/acc/')
def logout(request, *args, **kwargs): return auth_logout(request, template_name='bazaar/registration/logged_out.html', *args, **kwargs)
def logout(request): """Logout a user. Actions available: Logout: Anyone""" return auth_logout(request, template_name='registration/logout.html')
def logout(request): response = auth_logout(request) messages.info(request, "Thanks for using Mile Tracker today! Come back soon.") return HttpResponseRedirect(reverse("landing"))
def logout(request): """View that logs out the user and redirects to home page.""" auth_logout(request) return redirect('phonebook:home')
def logout(request): "Custom logout view with next_page = settings.LOGIN_URL" return auth_logout(request, next_page=settings.LOGIN_URL)
"""mysite URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.1/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: path('', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin from django.urls import path from django.conf.urls import url, include from django.contrib.auth import views urlpatterns = [ path('admin/', admin.site.urls), url(r'^', include('blog.urls', namespace='blog')), url(r'^accounts/login/$', views.auth_login('login')), url(r'^accounts/logout/$', views.auth_logout('logout')), ]
def logout(request): response = auth_logout(request, next_page='/') messages.success(request, _("Logout successful")) return response
def logout(request): return auth_logout(request, template_name='registration/after_log_out.html', redirect_field_name='next')
def logout(request): auth_logout(request) return redirect('login')
def logout(request): auth_logout(request) return redirect('home')
def logout(request): auth_logout(request, request.user) return HttpResponseRedirect('/')
def logout_view(request): return auth_logout(request, template_name='registration/logout.html', extra_context=site_name(request))
def logout(request): user = request.user if user.is_authenticated(): messages.add_message(request, info_messages['logged out'][0],info_messages['logged out'][1]) return auth_logout(request,next_page=reverse('user_session:login'))
def logout(request): auth_logout(request) return redirect(reverse('index'))
def logout(request): if request.method == 'POST': auth_views.auth_logout(request) return redirect('/login')
def logout_view(request): if request.user: auth_logout(request) return redirect('/accounts/login')
def logout(request): return auth_logout(request)
def create_poll(request): if not request.user.is_authenticated: return redirect('login') error = False # @todo: create a form class for that. this is very ugly. if request.method == 'POST': if not 'sc_token' in request.session: return redirect("/") required_fields = ["question", "answers[]", "expire-at"] for field in required_fields: if not request.POST.get(field): error = True messages.add_message(request, messages.ERROR, f"{field} field is required.") question = request.POST.get("question") choices = request.POST.getlist("answers[]") expire_at = request.POST.get("expire-at") if question: if not (4 < len(question) < 256): messages.add_message( request, messages.ERROR, "Question text should be between 6-256 chars.") error = True if 'choices' in request.POST: if len(choices) < 2: messages.add_message(request, messages.ERROR, f"At least 2 choices are required.") error = True elif len(choices) > 20: messages.add_message(request, messages.ERROR, f"Maximum number of choices is 20.") error = True if 'expire-at' in request.POST: if expire_at not in ["1_week", "1_month"]: messages.add_message(request, messages.ERROR, f"Invalid expiration value.") error = True if error: return render(request, "add.html") days = 7 if expire_at == "1_week" else 30 # add the question permlink = slugify(question)[0:256] if not permlink: permlink = str(uuid.uuid4()) # @todo: also check for duplicates in the blockchain. # client.get_content() if (Question.objects.filter(permlink=permlink, username=request.user)).exists(): messages.add_message(request, messages.ERROR, "You have already a similar poll.") return redirect('create-poll') question = Question(text=question, username=request.user.username, description=request.POST.get("description"), permlink=permlink, expire_at=now() + timedelta(days=days)) question.save() # add answers attached to it for choice in choices: choice_instance = Choice( question=question, text=choice, ) choice_instance.save() # send it to the steem blockchain sc_client = Client(access_token=request.session.get("sc_token")) comment = Comment(author=request.user.username, permlink=question.permlink, body=get_body( question, choices, request.user.username, permlink, ), title=question.text, parent_permlink=settings.COMMUNITY_TAG, json_metadata={ "tags": settings.DEFAULT_TAGS, "app": f"dpoll/{settings.DPOLL_APP_VERSION}", "content_type": "poll", "question": question.text, "description": question.description or "", "choices": choices, "expire_at": str(question.expire_at), }) comment_options = get_comment_options(comment) resp = sc_client.broadcast([ comment.to_operation_structure(), comment_options.to_operation_structure(), ]) if 'error' in resp: if 'The token has invalid role' in resp.get("error_description"): # expired token auth_logout(request) return redirect('login') messages.add_message(request, messages.ERROR, resp.get("error_description", "error")) question.delete() return redirect('create-poll') return redirect('detail', question.username, question.permlink) return render(request, "add.html")
def logout(request): auth_logout(request) return redirect('base.html')
def create_poll(request): if not request.user.is_authenticated: return redirect('login') if request.method == 'POST': form_data = copy.copy(request.POST) if 'sc_token' not in request.session: return redirect("/") error, question, choices, expire_at, permlink, days, tags, \ allow_multiple_choices = validate_input(request) if error: form_data.update({ "answers": request.POST.getlist("answers[]"), "expire_at": request.POST.get("expire-at"), "reward_option": request.POST.get("reward-option"), "allow_multiple_choices": request.POST.get("allow-multiple-choices"), }) return render(request, "add.html", {"form_data": form_data}) if (Question.objects.filter(permlink=permlink, username=request.user)).exists(): messages.add_message(request, messages.ERROR, "You have already a similar poll.") return redirect('create-poll') # add question question = add_or_get_question(request, question, permlink, days, allow_multiple_choices) question.save() # add answers attached to it add_choices(question, choices) # send it to the steem blockchain sc_client = Client(access_token=request.session.get("sc_token"), oauth_base_url="https://hivesigner.com/oauth2/", sc2_api_base_url="https://hivesigner.com/api/") comment = get_comment(request, question, choices, permlink, tags) comment_options = get_comment_options( comment, reward_option=request.POST.get("reward-option")) if not settings.BROADCAST_TO_BLOCKCHAIN: resp = {} else: resp = sc_client.broadcast([ comment.to_operation_structure(), comment_options.to_operation_structure(), ]) if 'error' in resp: if 'The token has invalid role' in resp.get("error_description"): # expired token auth_logout(request) return redirect('login') messages.add_message(request, messages.ERROR, resp.get("error_description", "error")) question.delete() return redirect('create-poll') return redirect('detail', question.username, question.permlink) return render(request, "add.html")
def logout(request): return auth_logout(request, next_page=reverse('dispatches'))
def logout_view(request): return auth_logout(request, template_name='registration/logout.html')
def logout(request, next_page): """Log out of Plinth and remove auth_pubtkt cookie""" response = auth_logout(request, next_page=next_page) response.delete_cookie(SSO_COOKIE_NAME) return response
def logout(request): auth_logout(request) return redirect('blog:index')
def sc_logout(request): auth_logout(request) return redirect("/")
def logout(request, next_page='/'): messages.success(request, "You've been successfully logged out.") return auth_logout(request, next_page=next_page)
def edit_poll(request, author, permlink): if not request.user.is_authenticated: return redirect('login') try: poll = Question.objects.get( permlink=permlink, username=author, ) except Question.DoesNotExist: raise Http404 if author != request.user.username: raise Http404 if request.method == "GET": poll_data = fetch_poll_data(poll.username, poll.permlink) tags = poll_data.get("tags", []) tags = [tag for tag in tags if tag not in settings.DEFAULT_TAGS] form_data = { "question": poll.text, "description": poll.description, "answers": [c.text for c in Choice.objects.filter(question=poll)], "expire_at": poll.expire_at_humanized, "tags": ",".join(tags), "allow_multiple_choices": poll.allow_multiple_choices } if request.method == 'POST': form_data = copy.copy(request.POST) if 'sc_token' not in request.session: return redirect("/") error, question, choices, expire_at, _, days, tags, \ allow_multiple_choices = validate_input(request) if tags: tags = settings.DEFAULT_TAGS + tags else: tags = settings.DEFAULT_TAGS permlink = poll.permlink if error: form_data.update({ "answers": request.POST.getlist("answers[]"), "expire_at": request.POST.get("expire-at"), "allow_multiple_choices": request.POST.get("allow-multiple-choices"), }) return render(request, "edit.html", {"form_data": form_data}) # add question question = add_or_get_question(request, question, permlink, days, allow_multiple_choices) question.save() # add answers attached to it add_choices(question, choices, flush=True) # send it to the steem blockchain sc_client = Client(access_token=request.session.get("sc_token"), oauth_base_url="https://hivesigner.com/oauth2/", sc2_api_base_url="https://hivesigner.com/api/") comment = get_comment(request, question, choices, permlink, tags=tags) if not settings.BROADCAST_TO_BLOCKCHAIN: resp = {} else: resp = sc_client.broadcast([ comment.to_operation_structure(), ]) if 'error' in resp: if 'The token has invalid role' in resp.get("error_description"): # expired token auth_logout(request) return redirect('login') messages.add_message(request, messages.ERROR, resp.get("error_description", "error")) question.delete() return redirect('edit', args=(author, permlink)) return redirect('detail', question.username, question.permlink) return render(request, "edit.html", { "form_data": form_data, })
def readerlogout(request): return auth_logout(request, next_page = reverse('reader:index'))
def logout(request): """Logs out user""" auth_logout(request) return redirect('/')
def get(self, request): auth_views.auth_logout(request) return HttpResponseRedirect(reverse_lazy('participate:login'))
def get(self, request, *args, **kwargs): return auth_logout(request, template_name=self.get_template_names(), *args, **kwargs)
def logout(request): auth_logout(request) return render(request, "REAccount/logout.html")
def get(self, request, *args, **kwargs): auth_logout(request) return HttpResponseRedirect(reverse('index'))