flows: add invalidation designation, use as default logout action
This commit is contained in:
@ -40,7 +40,7 @@
|
||||
</div>
|
||||
<div class="pf-c-page__header-tools">
|
||||
<div class="pf-c-page__header-tools-group pf-m-icons">
|
||||
<a href="{% url 'passbook_core:auth-logout' %}" class="pf-c-button pf-m-plain" type="button">
|
||||
<a href="{% url 'passbook_flows:default-invalidation' %}" class="pf-c-button pf-m-plain" type="button">
|
||||
<i class="fas fa-sign-out-alt" aria-hidden="true"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
@ -1,45 +0,0 @@
|
||||
"""passbook Core Account Test"""
|
||||
import string
|
||||
from random import SystemRandom
|
||||
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from passbook.core.models import User
|
||||
|
||||
|
||||
class TestAuthenticationViews(TestCase):
|
||||
"""passbook Core Account Test"""
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.sign_up_data = {
|
||||
"name": "Test",
|
||||
"username": "beryjuorg",
|
||||
"email": "unittest@passbook.beryju.org",
|
||||
"password": "B3ryju0rg!",
|
||||
"password_repeat": "B3ryju0rg!",
|
||||
}
|
||||
self.login_data = {
|
||||
"uid_field": "unittest@example.com",
|
||||
}
|
||||
self.user = User.objects.create_superuser(
|
||||
username="unittest user",
|
||||
email="unittest@example.com",
|
||||
password="".join(
|
||||
SystemRandom().choice(string.ascii_uppercase + string.digits)
|
||||
for _ in range(8)
|
||||
),
|
||||
)
|
||||
|
||||
def test_logout_view(self):
|
||||
"""Test account.logout view"""
|
||||
self.client.force_login(self.user)
|
||||
response = self.client.get(reverse("passbook_core:auth-logout"))
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
def test_sign_up_view_auth(self):
|
||||
"""Test account.sign_up view (Authenticated)"""
|
||||
self.client.force_login(self.user)
|
||||
response = self.client.get(reverse("passbook_core:auth-logout"))
|
||||
self.assertEqual(response.status_code, 302)
|
@ -1,11 +1,9 @@
|
||||
"""passbook URL Configuration"""
|
||||
from django.urls import path
|
||||
|
||||
from passbook.core.views import authentication, overview, user
|
||||
from passbook.core.views import overview, user
|
||||
|
||||
urlpatterns = [
|
||||
# Authentication views
|
||||
path("auth/logout/", authentication.LogoutView.as_view(), name="auth-logout"),
|
||||
# User views
|
||||
path("-/user/", user.UserSettingsView.as_view(), name="user-settings"),
|
||||
path("-/user/delete/", user.UserDeleteView.as_view(), name="user-delete"),
|
||||
|
@ -1,21 +0,0 @@
|
||||
"""passbook core authentication views"""
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import logout
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.shortcuts import redirect, reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views import View
|
||||
from structlog import get_logger
|
||||
|
||||
LOGGER = get_logger()
|
||||
|
||||
|
||||
class LogoutView(LoginRequiredMixin, View):
|
||||
"""Log current user out"""
|
||||
|
||||
def dispatch(self, request: HttpRequest) -> HttpResponse:
|
||||
"""Log current user out"""
|
||||
logout(request)
|
||||
messages.success(request, _("You've successfully been logged out."))
|
||||
return redirect(reverse("passbook_flows:default-auth"))
|
Reference in New Issue
Block a user