Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[18.0][MIG] impersonate_login #714

Open
wants to merge 11 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions impersonate_login/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
=================
Impersonate Login
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1fca331cbc5f2dcb804e5612e5669a9ab4998d80f22d46d6683266580f9ca40f
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
:target: https://github.com/OCA/server-auth/tree/18.0/impersonate_login
:alt: OCA/server-auth
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-auth-18-0/server-auth-18-0-impersonate_login
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows one user (for example, a member of the support team)
to log in as another user. The impersonation session can be exited by
clicking on the button "Back to Original User".

To ensure that any abuse of this feature will not go unnoticed, the
following measures are in place:

- In the chatter, it is displayed who is the user that is logged as
another user.
- Mails and messages are sent from the original user.
- Impersonated logins are logged and can be consulted through the
Settings -> Technical menu.
-

There is an alternative module to allow logins as another user
(auth_admin_passkey), but it does not support these security mechanisms.

**Table of contents**

.. contents::
:local:

Configuration
=============

The impersonating user must belong to group "Impersonate Users".

Usage
=====

1. In the menu that is displayed when clicking on the user avatar on the
top right corner, or in the res.users list, click "Switch Login" to
impersonate another user.
2. On the top-right corner, the button "Back to Original User" is
displayed in case the current user is being impersonated.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20impersonate_login%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Akretion

Contributors
------------

- Kévin Roche <[email protected]>
- `360ERP <https://www.360erp.com>`__:

- Andrea Stirpe

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-Kev-Roche| image:: https://github.com/Kev-Roche.png?size=40px
:target: https://github.com/Kev-Roche
:alt: Kev-Roche

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Kev-Roche|

This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/18.0/impersonate_login>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions impersonate_login/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import pre_init_hook
32 changes: 32 additions & 0 deletions impersonate_login/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Akretion (https://www.akretion.com).
# @author Kévin Roche <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
"name": "Impersonate Login",
"summary": "tools",
"version": "18.0.1.0.0",
"category": "Tools",
"website": "https://github.com/OCA/server-auth",
"author": "Akretion, Odoo Community Association (OCA)",
"maintainers": ["Kev-Roche"],
"license": "AGPL-3",
"application": False,
"installable": True,
"depends": [
"web",
"mail",
],
"data": [
"security/group.xml",
"security/ir.model.access.csv",
"views/res_users.xml",
"views/impersonate_log.xml",
],
"assets": {
"web.assets_backend": [
"impersonate_login/static/src/js/user_menu.esm.js",
],
},
"pre_init_hook": "pre_init_hook",
}
19 changes: 19 additions & 0 deletions impersonate_login/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 360ERP (<https://www.360erp.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging


def pre_init_hook(env):
"""
Pre-create the impersonated_author_id column in the mail_message table
to prevent the ORM from invoking its compute method on a large volume
of existing mail messages.
"""
logger = logging.getLogger(__name__)
logger.info("Add mail_message.impersonated_author_id column if not exists")
env.cr.execute(
"ALTER TABLE mail_message "
"ADD COLUMN IF NOT EXISTS "
"impersonated_author_id INTEGER"
)
154 changes: 154 additions & 0 deletions impersonate_login/i18n/impersonate_login.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * impersonate_login
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: impersonate_login
#. odoo-javascript
#: code:addons/impersonate_login/static/src/js/user_menu.esm.js:0
#, python-format
msgid "Back to Original User"
msgstr ""

#. module: impersonate_login
#: model:ir.model,name:impersonate_login.model_base
msgid "Base"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_mail_mail__body
#: model:ir.model.fields,field_description:impersonate_login.field_mail_message__body
msgid "Contents"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__create_uid
msgid "Created by"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__create_date
msgid "Created on"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__display_name
msgid "Display Name"
msgstr ""

#. module: impersonate_login
#: model:ir.model,name:impersonate_login.model_mail_thread
msgid "Email Thread"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__date_end
msgid "End Date"
msgstr ""

#. module: impersonate_login
#: model:ir.model,name:impersonate_login.model_ir_http
msgid "HTTP Routing"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__id
msgid "ID"
msgstr ""

#. module: impersonate_login
#: model:ir.actions.act_window,name:impersonate_login.impersonate_log_action
msgid "Impersonate Login Logs"
msgstr ""

#. module: impersonate_login
#: model:ir.model,name:impersonate_login.model_impersonate_log
msgid "Impersonate Logs"
msgstr ""

#. module: impersonate_login
#: model:res.groups,name:impersonate_login.group_impersonate_login
msgid "Impersonate Users"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_mail_mail__impersonated_author_id
#: model:ir.model.fields,field_description:impersonate_login.field_mail_message__impersonated_author_id
msgid "Impersonated Author"
msgstr ""

#. module: impersonate_login
#: model:ir.ui.menu,name:impersonate_login.menu_impersonate_log
msgid "Impersonated Logs"
msgstr ""

#. module: impersonate_login
#. odoo-python
#: code:addons/impersonate_login/models/res_users.py:0
#, python-format
msgid "It's you."
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__write_uid
msgid "Last Updated by"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__write_date
msgid "Last Updated on"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__impersonated_partner_id
msgid "Logged as"
msgstr ""

#. module: impersonate_login
#. odoo-python
#: code:addons/impersonate_login/models/mail_message.py:0
#: code:addons/impersonate_login/models/mail_message.py:0
#, python-format
msgid "Logged in as {}"
msgstr ""

#. module: impersonate_login
#: model:ir.model,name:impersonate_login.model_mail_message
msgid "Message"
msgstr ""

#. module: impersonate_login
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__date_start
msgid "Start Date"
msgstr ""

#. module: impersonate_login
#. odoo-javascript
#: code:addons/impersonate_login/static/src/js/user_menu.esm.js:0
#: model_terms:ir.ui.view,arch_db:impersonate_login.impersonate_res_users_tree
#, python-format
msgid "Switch Login"
msgstr ""

#. module: impersonate_login
#: model:ir.model,name:impersonate_login.model_res_users
#: model:ir.model.fields,field_description:impersonate_login.field_impersonate_log__user_id
msgid "User"
msgstr ""

#. module: impersonate_login
#. odoo-python
#: code:addons/impersonate_login/models/res_users.py:0
#, python-format
msgid "You are already Logged as another user."
msgstr ""
Loading
Loading