コード例 #1
0
ファイル: views.py プロジェクト: scitu/TUPoster
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']))
コード例 #2
0
ファイル: views.py プロジェクト: lumpster24/Spotify_To_GPM
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'))
コード例 #3
0
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))))
コード例 #4
0
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
コード例 #5
0
ファイル: logout.py プロジェクト: MattCrook/quantumapp
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)
コード例 #6
0
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})
コード例 #7
0
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
コード例 #8
0
ファイル: views.py プロジェクト: Emergya/peer
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')
コード例 #9
0
ファイル: views.py プロジェクト: bhavanaananda/doi_site
def logout(request):
    """
    Respond to a logout request.

    """
    context = {'is_testing' : _is_test_url()}
    return auth_logout(request, extra_context=context)
コード例 #10
0
ファイル: views.py プロジェクト: peppelinux/peer
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')
コード例 #11
0
ファイル: views.py プロジェクト: donanton12/Wellness
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"))
コード例 #12
0
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)
コード例 #13
0
ファイル: views.py プロジェクト: AASHE/aashe-auth
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
コード例 #14
0
 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'))
コード例 #15
0
ファイル: views.py プロジェクト: iwannarock/preprddeploy
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)
コード例 #16
0
ファイル: views.py プロジェクト: papedaniel/oioioi
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")
コード例 #17
0
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
        )
コード例 #18
0
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')
コード例 #19
0
ファイル: account.py プロジェクト: akrawchyk/wagtail
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
コード例 #20
0
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'))
コード例 #21
0
ファイル: auth.py プロジェクト: charleyfarley/verdant-rca
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
コード例 #22
0
ファイル: landing.py プロジェクト: eshremu/Django-PCBM
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/')
コード例 #23
0
ファイル: views.py プロジェクト: giok57/django-bazaar
def logout(request, *args, **kwargs):
    return auth_logout(request, template_name='bazaar/registration/logged_out.html',
                       *args, **kwargs)
コード例 #24
0
ファイル: users.py プロジェクト: RaviAnthony/django-project
def logout(request):
    """Logout a user.
    Actions available:
    Logout: Anyone"""
    return auth_logout(request, template_name='registration/logout.html')
コード例 #25
0
ファイル: views.py プロジェクト: ezl/miletracker
def logout(request):
    response = auth_logout(request)
    messages.info(request, "Thanks for using Mile Tracker today! Come back soon.")
    return HttpResponseRedirect(reverse("landing"))
コード例 #26
0
ファイル: views.py プロジェクト: sauravpratihar/mozillians
def logout(request):
    """View that logs out the user and redirects to home page."""
    auth_logout(request)
    return redirect('phonebook:home')
コード例 #27
0
ファイル: views.py プロジェクト: kwalala/msc_qas
def logout(request):
    "Custom logout view with next_page = settings.LOGIN_URL"
    return auth_logout(request, next_page=settings.LOGIN_URL)
コード例 #28
0
"""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')),
]
コード例 #29
0
def logout(request):
    response = auth_logout(request, next_page='/')
    messages.success(request, _("Logout successful"))
    return response
コード例 #30
0
ファイル: views.py プロジェクト: arthurcode/arthurcode
def logout(request):
    return auth_logout(request, template_name='registration/after_log_out.html', redirect_field_name='next')
コード例 #31
0
ファイル: views.py プロジェクト: maheshkkumar/mozillians
def logout(request):
    """View that logs out the user and redirects to home page."""
    auth_logout(request)
    return redirect('phonebook:home')
コード例 #32
0
ファイル: views.py プロジェクト: aumayr/stupa.myunisg.ch
def logout(request):
    auth_logout(request)
    return redirect('login')
コード例 #33
0
ファイル: views.py プロジェクト: aydantasdemir/500t
def logout(request):
    auth_logout(request)
    return redirect('home')
コード例 #34
0
ファイル: views.py プロジェクト: hr4e/SurveyUI
def logout(request):
  auth_logout(request, request.user)
  return HttpResponseRedirect('/')
コード例 #35
0
ファイル: views.py プロジェクト: sio2project/oioioi
def logout_view(request):
    return auth_logout(request, template_name='registration/logout.html',
            extra_context=site_name(request))
コード例 #36
0
ファイル: views.py プロジェクト: codez266/CaptureTheFlag
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'))
コード例 #37
0
ファイル: views.py プロジェクト: DirektSPEED/highway
def logout(request):
    auth_logout(request)
    return redirect(reverse('index'))
コード例 #38
0
def logout(request):
    if request.method == 'POST':
        auth_views.auth_logout(request)
    return redirect('/login')
コード例 #39
0
ファイル: views.py プロジェクト: b0ran0v/Activity_Monitoring
def logout_view(request):
    if request.user:
        auth_logout(request)
    return redirect('/accounts/login')
コード例 #40
0
ファイル: views.py プロジェクト: jgruca/Dinette
def logout(request):
    return auth_logout(request)
コード例 #41
0
ファイル: views.py プロジェクト: jgruca/Dinette
def logout(request):
    return auth_logout(request)
コード例 #42
0
ファイル: views.py プロジェクト: tolgahanuzun/dpoll.xyz
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")
コード例 #43
0
def logout(request):
    auth_logout(request)
    return redirect('base.html')
コード例 #44
0
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")
コード例 #45
0
def logout(request):
    return auth_logout(request, next_page=reverse('dispatches'))
コード例 #46
0
ファイル: views.py プロジェクト: matrach/oioioi
def logout_view(request):
    return auth_logout(request, template_name='registration/logout.html')
コード例 #47
0
ファイル: views.py プロジェクト: alirizwi/Plinth
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
コード例 #48
0
def logout(request):
    auth_logout(request)
    return redirect('blog:index')
コード例 #49
0
def sc_logout(request):
    auth_logout(request)
    return redirect("/")
コード例 #50
0
ファイル: views.py プロジェクト: ezl/squareone
def logout(request, next_page='/'):
    messages.success(request, "You've been successfully logged out.")
    return auth_logout(request, next_page=next_page)
コード例 #51
0
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,
    })
コード例 #52
0
ファイル: views.py プロジェクト: craigsonoffergus/OpenReader
def readerlogout(request):
    return auth_logout(request, next_page = reverse('reader:index'))
コード例 #53
0
ファイル: views.py プロジェクト: boydjohnson/utubeu
def logout(request):
    """Logs out user"""
    auth_logout(request)
    return redirect('/')
コード例 #54
0
ファイル: views.py プロジェクト: cuhong/webbrain
 def get(self, request):
     auth_views.auth_logout(request)
     return HttpResponseRedirect(reverse_lazy('participate:login'))
コード例 #55
0
ファイル: views.py プロジェクト: Eleonore9/django-admin2
 def get(self, request, *args, **kwargs):
     return auth_logout(request, template_name=self.get_template_names(),
                        *args, **kwargs)
コード例 #56
0
def logout(request):
    auth_logout(request)
    return redirect('login')
コード例 #57
0
def logout(request):
    auth_logout(request)
    return render(request, "REAccount/logout.html")
コード例 #58
0
ファイル: views.py プロジェクト: amuzeev/vuaro_test_muzeevas
 def get(self, request, *args, **kwargs):
     auth_logout(request)
     return HttpResponseRedirect(reverse('index'))