PR #75535 introduced trusted devices, but only made them visible in the main user form (for admins) and in the portal. It's quite useful for users to be able to view and manage their trusted devices in their own user preferences as well. This commit add them in the "Account Security" of the user profile. In addition: - improve the layout of the trusted devices by wrapping them in a <group> to have them stand out from the surrounding prefs - move the "Account is protected" label about the trusted devices, and under main the 2FA toggle button, where it's supposed to be. - removed the custom form view for trusted devices inside the one2many. The point was to hide the extra `scope` field, but it's not worth it, and the Cancel button wasn't even working, the default form view is better. - improve the confirmation message of the "Revoke All" button when it's located on the user management form (for admins) to clarify that it's not the admin's devices that will be revoked. - change the 2FA label from "Your Account is protected" to "This account is protected" when located on the user management form for admins. Note: this is a manual partial fwd-port of #94111, as this part was mistakenly dropped in the fwd-port chain at #94193 closes odoo/odoo#94869 X-original-commit: d3a7910788ceff856fc6a843876579d379ce9caf Signed-off-by: Olivier Dony <odo@odoo.com>
109 lines
7.5 KiB
XML
109 lines
7.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<record model="ir.ui.view" id="res_users_view_search">
|
|
<field name="name">res.users.view.search.inherit.auth.totp</field>
|
|
<field name="model">res.users</field>
|
|
<field name="inherit_id" ref="base.view_users_search" />
|
|
<field name="arch" type="xml">
|
|
<xpath expr="//search" position="inside">
|
|
<separator/>
|
|
<filter name="totp_enabled" string="Two-factor authentication Enabled" domain="[('totp_secret','!=',False)]"/>
|
|
<filter name="totp_disabled" string="Two-factor authentication Disabled" domain="[('totp_secret','=',False)]"/>
|
|
</xpath>
|
|
</field>
|
|
</record>
|
|
|
|
<record model="ir.ui.view" id="view_totp_form">
|
|
<field name="name">user form: add totp status</field>
|
|
<field name="model">res.users</field>
|
|
<field name="inherit_id" ref="base.view_users_form"/>
|
|
<field name="arch" type="xml">
|
|
<xpath expr="//page[@name='preferences']" position="after">
|
|
<page string="Account Security" name="security" attrs="{'invisible': [('id', '=', False)]}">
|
|
<field name="totp_enabled" invisible="1"/>
|
|
<!-- For own user, allow to activate the two-factor Authentication -->
|
|
<group>
|
|
<div>
|
|
<div class="o_horizontal_separator d-flex align-items-center mt-0">Two-factor Authentication
|
|
<div attrs="{'invisible': [('totp_enabled', '!=', False)]}">
|
|
<button attrs="{'invisible': "[('id', '=', uid)]"}" name="action_totp_enable_wizard"
|
|
disabled="1" type="object" class="fa fa-toggle-off o_auth_2fa_btn disabled" aria-label="Enable 2FA"></button>
|
|
<button attrs="{'invisible': "[('id', '!=', uid)]"}" name="action_totp_enable_wizard"
|
|
type="object" class="fa fa-toggle-off o_auth_2fa_btn disabled" aria-label="Enable 2FA"></button>
|
|
</div>
|
|
<button attrs="{'invisible': [('totp_enabled', '=', False)]}" name="action_totp_disable" type="object"
|
|
class="fa fa-toggle-on o_auth_2fa_btn text-primary enabled" aria-label="Disable 2FA"></button>
|
|
</div>
|
|
<span attrs="{'invisible': [('totp_enabled', '!=', False)]}" class="text-muted">
|
|
Two-factor Authentication ("2FA") is a system of double authentication.
|
|
The first one is done with your password and the second one with a code you get from a dedicated mobile app.
|
|
Popular ones include Authy, Google Authenticator or the Microsoft Authenticator.
|
|
<a href="https://www.odoo.com/documentation/master/applications/general/auth/2fa.html"
|
|
title="Learn More" target="_blank">Learn More</a>
|
|
</span>
|
|
<span attrs="{'invisible': [('totp_enabled', '=', False)]}" class="text-muted">This account is protected!</span>
|
|
<group name="auth_devices" string="Trusted Devices" attrs="{'invisible': [('totp_trusted_device_ids', '=', [])]}">
|
|
<div colspan="2">
|
|
<field name="totp_trusted_device_ids" nolabel="1" colspan="4" readonly="1">
|
|
<tree create="false" delete="false">
|
|
<field name="name" string="Device"/>
|
|
<field name="create_date" string="Added On"/>
|
|
<button type="object" name="remove"
|
|
title="Revoke" icon="fa-trash"/>
|
|
</tree>
|
|
</field>
|
|
<button name="revoke_all_devices" string="Revoke All" type="object" class="btn btn-secondary"
|
|
confirm="Are you sure? The user may be asked to enter two-factor codes again on those devices"/>
|
|
</div>
|
|
</group>
|
|
</div>
|
|
</group>
|
|
</page>
|
|
</xpath>
|
|
</field>
|
|
</record>
|
|
|
|
<record model="ir.ui.view" id="view_totp_field">
|
|
<field name="name">users preference: totp</field>
|
|
<field name="model">res.users</field>
|
|
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
|
|
<field name="arch" type="xml">
|
|
<group name="auth" position="after">
|
|
<field name="totp_enabled" invisible="1"/>
|
|
<group>
|
|
<div>
|
|
<div class="o_horizontal_separator mt-0">Two-factor Authentication
|
|
<button attrs="{'invisible': [('totp_enabled', '!=', False)]}" name="action_totp_enable_wizard"
|
|
type="object" class="fa fa-toggle-off o_auth_2fa_btn mb-1" aria-label="Enable 2FA"/>
|
|
<button attrs="{'invisible': [('totp_enabled', '=', False)]}" name="action_totp_disable"
|
|
type="object" class="fa fa-toggle-on o_auth_2fa_btn text-primary" aria-label="Disable 2FA"/>
|
|
</div>
|
|
<span attrs="{'invisible': [('totp_enabled', '=', False)]}" class="text-muted">Your account is protected!</span>
|
|
<span attrs="{'invisible': [('totp_enabled', '!=', False)]}" class="text-muted">
|
|
Two-factor Authentication ("2FA") is a system of double authentication.
|
|
The first one is done with your password and the second one with a code you get from a dedicated mobile app.
|
|
Popular ones include Authy, Google Authenticator or the Microsoft Authenticator.
|
|
<a href="https://www.odoo.com/documentation/master/applications/general/auth/2fa.html"
|
|
title="Learn More" target="_blank">Learn More</a>
|
|
</span>
|
|
<group name="auth_devices" string="Trusted Devices" attrs="{'invisible': [('totp_trusted_device_ids', '=', [])]}">
|
|
<div colspan="2">
|
|
<field name="totp_trusted_device_ids" nolabel="1" colspan="4" readonly="1">
|
|
<tree create="false" delete="false">
|
|
<field name="name" string="Device"/>
|
|
<field name="create_date" string="Added On"/>
|
|
<button type="object" name="remove"
|
|
title="Revoke" icon="fa-trash"/>
|
|
</tree>
|
|
</field>
|
|
<button name="revoke_all_devices" string="Revoke All" type="object" class="btn btn-secondary"
|
|
confirm="Are you sure? You may be asked to enter two-factor codes again on those devices"/>
|
|
</div>
|
|
</group>
|
|
</div>
|
|
</group>
|
|
</group>
|
|
</field>
|
|
</record>
|
|
</odoo>
|