django-loginas icon indicating copy to clipboard operation
django-loginas copied to clipboard

Add documentation for usage in templates

Open juancresc opened this issue 2 years ago • 3 comments

Is it something like this maybe:

<a class="sm" href="{% url 'loginas-user-login' user_id=other_user.id %}">login as</a>

juancresc avatar Jan 25 '23 19:01 juancresc

This is useful, could you file a PR? I haven't touched the template code in a while.

skorokithakis avatar Jan 27 '23 20:01 skorokithakis

actually this is what im doing, maybe I can add this


<a id="loginas-link" data-id="{{ u.pk }}" href="#">
    log in as
</a>
<form data-loginas="{{ u.pk }}" method="post" id="loginas-form"
  action="{% url 'loginas-user-login' u.id %}" style="display: none">
  {% csrf_token %}
</form>
$('a[id="loginas-link"]').on('click', function () {
  var id = $(this).data('id');
  $('#loginas-form[data-loginas="' + id + '"]').submit();
});

juancresc avatar Jan 27 '23 21:01 juancresc

This looks like it requires jQuery, though, which not everyone might load. If you have a template that works, its name, and its path, I can add it to the docs.

skorokithakis avatar Jan 27 '23 21:01 skorokithakis