mirror of
https://github.com/retspen/webvirtcloud
synced 2025-07-31 12:41:08 +00:00
logger updates (#31)
* Log for failed login attempts * Logger configuration for logging to file * interface fixes * login log fix, added logged in too * bootstrap icons setup * font-awesome icons replaced with bootstrap icons * replaced i-tags with django_bootstrap_icons * removed icons library from project * bug fix --------- Co-authored-by: catborise <catborise@gmail.com>
This commit is contained in:
parent
07d7a6d752
commit
1cbdf76df6
59 changed files with 344 additions and 291 deletions
|
@ -1,7 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load i18n %}
|
||||
{% load icons %}
|
||||
{% load bootstrap_icons %}
|
||||
{% load qr_code %}
|
||||
|
||||
{% block title %}{% trans "User Profile" %} - {{ user }}{% endblock %}
|
||||
|
@ -10,14 +10,14 @@
|
|||
{% block page_heading_extra %}
|
||||
{% if otp_enabled %}
|
||||
<a href="{% url 'accounts:admin_email_otp' user.id %}" class="btn btn-secondary" title="{% trans "Email OTP QR code" %}">
|
||||
{% icon 'qrcode' %}
|
||||
{% bs_icon 'qr-code' %}
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{% url 'admin:user_update' user.id %}?next={% url 'accounts:account' user.id %}" class="btn btn-primary" title="{% trans "Edit user" %}">
|
||||
{% icon 'pencil' %}
|
||||
{% bs_icon 'pencil' %}
|
||||
</a>
|
||||
<a href="{% url 'accounts:user_instance_create' user.id %}" class="btn btn-success" title="{% trans "Create user instance" %}">
|
||||
{% icon 'plus' %}
|
||||
{% bs_icon 'plus' %}
|
||||
</a>
|
||||
{% endblock page_heading_extra %}
|
||||
|
||||
|
@ -58,12 +58,12 @@
|
|||
<td>{{ inst.is_delete }}</td>
|
||||
<td style="width:5px;">
|
||||
<a href="{% url 'accounts:user_instance_update' inst.id %}" class="btn btn-sm btn-secondary" title="{% trans "edit" %}">
|
||||
{% icon 'pencil' %}
|
||||
{% bs_icon 'pencil' %}
|
||||
</a>
|
||||
</td>
|
||||
<td style="width:5px;">
|
||||
<a class="btn btn-sm btn-secondary" href="{% url 'accounts:user_instance_delete' inst.id %}" title="{% trans "Delete" %}">
|
||||
{% icon 'trash' %}
|
||||
{% bs_icon 'trash' %}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% load django_bootstrap5 %}
|
||||
{% load i18n %}
|
||||
{% load icons %}
|
||||
{% load bootstrap_icons %}
|
||||
|
||||
{% block title %}{%trans "Change Password" %}{% endblock title %}
|
||||
|
||||
|
@ -21,10 +21,10 @@
|
|||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="float-end">
|
||||
<a class="btn btn-primary" href="javascript:history.back()">{% icon 'times' %}
|
||||
<a class="btn btn-primary" href="javascript:history.back()">{% bs_icon 'x' %}
|
||||
{% trans "Cancel" %}</a>
|
||||
<button type="submit" form="password-change" class="btn btn-success">
|
||||
{% icon 'check' %} {% trans "Change" %}
|
||||
{% bs_icon 'check2' %} {% trans "Change" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load django_bootstrap5 %}
|
||||
{% load icons %}
|
||||
{% load bootstrap_icons %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
@ -22,9 +22,9 @@
|
|||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="mb-0 float-end">
|
||||
<a class="btn btn-primary" href="javascript:history.back()">{% icon 'arrow-left' %} {% trans "Cancel" %}</a>
|
||||
<a class="btn btn-primary" href="javascript:history.back()">{% bs_icon 'arrow-left' %} {% trans "Cancel" %}</a>
|
||||
<button type="submit" form="create-update" class="btn btn-success">
|
||||
{% icon 'envelope-o' %} {% trans "Send" %}
|
||||
{% bs_icon 'envelope-open' %} {% trans "Send" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load django_bootstrap5 %}
|
||||
{% load icons %}
|
||||
{% load bootstrap_icons %}
|
||||
{% load tags_fingerprint %}
|
||||
|
||||
{% block title %}{% trans "Profile" %}: {{ request.user.first_name }} {{ request.user.last_name}}{% endblock %}
|
||||
|
@ -30,12 +30,12 @@
|
|||
{% bootstrap_form profile_form layout='horizontal' %}
|
||||
{% if perms.accounts.change_password %}
|
||||
<a href="{% url 'accounts:change_password' %}" class="btn btn-primary">
|
||||
{% icon 'lock' %} {% trans "Change Password" %}
|
||||
{% bs_icon 'lock' %} {% trans "Change Password" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
<div class="mb-0 float-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{% icon 'pencil' %} {% trans "Update" %}
|
||||
{% bs_icon 'pencil' %} {% trans "Update" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -53,7 +53,7 @@
|
|||
<td>{{ key.keyname }} ({% ssh_to_fingerprint key.keypublic %})</td>
|
||||
<td>
|
||||
<a href="{% url 'accounts:ssh_key_delete' key.id %}" title="{% trans "Delete" %}" class="btn btn-sm btn-secondary">
|
||||
{% icon 'trash' %}
|
||||
{% bs_icon 'trash' %}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -73,7 +73,7 @@
|
|||
{% bootstrap_form ssh_key_form layout='horizontal' %}
|
||||
<div class="mb-0 float-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{% icon 'plus' %} {% trans "Add" %}
|
||||
{% bs_icon 'plus' %} {% trans "Add" %}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -4,6 +4,7 @@ from django.urls import path
|
|||
from django_otp.forms import OTPAuthenticationForm
|
||||
|
||||
from . import views
|
||||
from .views import CustomLoginView
|
||||
|
||||
app_name = "accounts"
|
||||
|
||||
|
@ -50,5 +51,5 @@ if settings.OTP_ENABLED:
|
|||
]
|
||||
else:
|
||||
urlpatterns += (
|
||||
path("login/", LoginView.as_view(template_name="login.html"), name="login"),
|
||||
path("login/", CustomLoginView.as_view(template_name="login.html"), name="login"),
|
||||
)
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from admin.decorators import superuser_only
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import get_user_model, update_session_auth_hash
|
||||
from django.contrib.auth import get_user_model, update_session_auth_hash, login as auth_login
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.contrib.auth.forms import PasswordChangeForm
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.urls import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from instances.models import Instance
|
||||
|
||||
|
@ -14,7 +15,20 @@ from accounts.models import *
|
|||
|
||||
from . import forms
|
||||
from .utils import get_user_totp_device, send_email_with_otp
|
||||
from django.contrib.auth.views import LoginView
|
||||
from logs.views import addlogmsg
|
||||
|
||||
class CustomLoginView(LoginView):
|
||||
def form_valid(self, form):
|
||||
username = form.cleaned_data['username']
|
||||
addlogmsg(username, "-", "-", "Logged In")
|
||||
auth_login(self.request, form.get_user())
|
||||
return HttpResponseRedirect(self.get_success_url())
|
||||
|
||||
def form_invalid(self, form):
|
||||
username = form.cleaned_data['username']
|
||||
addlogmsg(username, "-", "-", "Failed Login Attempt")
|
||||
return self.render_to_response(self.get_context_data(form=form))
|
||||
|
||||
def profile(request):
|
||||
publickeys = UserSSHKey.objects.filter(user_id=request.user.id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue