mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 11:46:49 +00:00
The user page a superuser opens from the user list has an API Tokens
tab: the user's tokens with their name, first characters, creation,
expiry and last use, and a delete button for one that may have leaked.
The token itself is never shown; only its digest is kept.
The delete reuses the owner's delete view with the user's id; only a
superuser may name another user. The confirmation and the log row say
whose token it was ("API token backup of alice"); the owner's own
confirmation now reads "Delete "API token backup"?" too. The profile
and the user page share one token table, and one script that opens a
tab named in the address (#apitokens).
61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
from django.conf import settings
|
|
from django.contrib.auth.views import LoginView, LogoutView
|
|
from django.urls import path
|
|
|
|
from . import views
|
|
from .forms import LoginForm
|
|
from .otp import SingleDeviceOTPForm
|
|
|
|
app_name = "accounts"
|
|
|
|
urlpatterns = [
|
|
path("logout/", LogoutView.as_view(template_name="logout.html"), name="logout"),
|
|
path("profile/", views.profile, name="profile"),
|
|
path("profile/<int:user_id>/", views.account, name="account"),
|
|
path("profile/<int:user_id>/api_token/<str:token_key>/delete/", views.api_token_delete,
|
|
name="account_api_token_delete"),
|
|
path("change_password/", views.change_password, name="change_password"),
|
|
path(
|
|
"user_instance/create/<int:user_id>/",
|
|
views.user_instance_create,
|
|
name="user_instance_create",
|
|
),
|
|
path(
|
|
"user_instance/<int:pk>/update/",
|
|
views.user_instance_update,
|
|
name="user_instance_update",
|
|
),
|
|
path(
|
|
"user_instance/<int:pk>/delete/",
|
|
views.user_instance_delete,
|
|
name="user_instance_delete",
|
|
),
|
|
path("ssh_key/create/", views.ssh_key_create, name="ssh_key_create"),
|
|
path("ssh_key/<int:pk>/delete/", views.ssh_key_delete, name="ssh_key_delete"),
|
|
path("api_token/create/", views.api_token_create, name="api_token_create"),
|
|
path("api_token/<str:token_key>/delete/", views.api_token_delete, name="api_token_delete"),
|
|
path("email_otp/", views.email_otp, name="email_otp"),
|
|
path(
|
|
"admin_email_otp/<int:user_id>/",
|
|
views.admin_email_otp,
|
|
name="admin_email_otp",
|
|
),
|
|
]
|
|
|
|
if settings.OTP_ENABLED:
|
|
urlpatterns += [
|
|
path(
|
|
"login/",
|
|
LoginView.as_view(
|
|
template_name="accounts/otp_login.html",
|
|
authentication_form=SingleDeviceOTPForm,
|
|
redirect_authenticated_user=True,
|
|
),
|
|
name="login",
|
|
),
|
|
]
|
|
else:
|
|
urlpatterns += (
|
|
path("login/", LoginView.as_view(template_name="login.html", authentication_form=LoginForm,
|
|
redirect_authenticated_user=True), name="login"),
|
|
)
|