Impersonation system implementation
This commit is contained in:
@@ -16,6 +16,14 @@
|
||||
<div class="profile-info">
|
||||
<h1>{{ profile_user.username }}</h1>
|
||||
<p class="profile-joined"><i class="fas fa-calendar"></i> Joined {{ profile.joined|date:"F j, Y" }}</p>
|
||||
{% if can_impersonate %}
|
||||
<form method="post" action="{% url 'profiles:impersonate_start' profile_user.pk %}" class="impersonate-form">
|
||||
{% csrf_token %}
|
||||
<button type="submit" class="btn btn-secondary" id="impersonate-btn">
|
||||
<i class="fas fa-mask"></i> Impersonate
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{% if is_owner %}
|
||||
<p><a href="{% url 'profiles:account' %}" class="btn btn-secondary"><i class="fas fa-cog"></i> Account Settings</a></p>
|
||||
{% endif %}
|
||||
@@ -78,6 +86,28 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
{% if can_impersonate %}
|
||||
<script>
|
||||
(function () {
|
||||
const btn = document.getElementById('impersonate-btn');
|
||||
if (!btn) return;
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const reason = prompt('Reason for impersonation (optional):', '');
|
||||
if (reason === null) return;
|
||||
const form = btn.closest('form');
|
||||
if (reason.trim()) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'hidden';
|
||||
input.name = 'reason';
|
||||
input.value = reason.trim();
|
||||
form.appendChild(input);
|
||||
}
|
||||
form.submit();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{% endif %}
|
||||
{% if is_owner %}
|
||||
<script>
|
||||
(function () {
|
||||
|
||||
Reference in New Issue
Block a user