mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 11:46:49 +00:00
The Logs page shows who added, changed or deleted a compute, from web or API, and every login, failed login, lockout and logout, with the client address and a Result column (Done, Failed, Unknown for older rows). A failed change is recorded with its reason and the error still reaches the user; a refused one is recorded too. - logs.audit.write saves each row in its own savepoint and never raises, so a log write cannot break or undo the action it records. The audit() context manager writes one row when the change ends. - Logs gains success and ip; user, host and instance are wider and date is indexed. The page orders by date then id. - A compute edit names the changed fields; an edit that changes nothing writes no row, and an empty password field is no change. - A compute's VMs leaving the panel get a system row each: owners kept on the Removed VMs page, moved to another compute, restored, left without owners, or the removed record expired. - Job rows carry the result. A job's log entry that cannot be computed is logged and skipped instead of rolling back the finish (test_service.py changes this on purpose). - Logins are recorded by signal receivers; CustomLoginView is removed and the plain LoginView is used. A wrong OTP code is a failed login, counted by django-axes toward the lockout. Panel records and host-side objects follow in the next layers.
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
from django.conf import settings
|
|
from django.contrib.auth.views import LoginView, LogoutView
|
|
from django.urls import path
|
|
|
|
from . import views
|
|
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("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("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", redirect_authenticated_user=True), name="login"),
|
|
)
|