diff options
| author | Xavier Morel <xmo@odoo.com> | 2020-08-20 09:25:32 +0000 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2020-09-10 12:50:20 +0000 |
| commit | f91970f4d9288e97cc9b3f3846472515078fc29a (patch) | |
| tree | 1c7e1aa32c2aca3ee36ae2e63fe7e83862c0686a /addons/auth_totp | |
| parent | 01725a210ebab3790d254ebca4a81d35db9e0e90 (diff) | |
[IMP] auth_totp: label of totp_enabled field & show status in form
Use same look in form as in preferences dialog, just without the
buttons to enable / disable it (technically could have the button to
disable with the correct group I guess?)
Diffstat (limited to 'addons/auth_totp')
| -rw-r--r-- | addons/auth_totp/models/res_users.py | 2 | ||||
| -rw-r--r-- | addons/auth_totp/views/user_preferences.xml | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/addons/auth_totp/models/res_users.py b/addons/auth_totp/models/res_users.py index 5fd8b4e4acd..070e51a3590 100644 --- a/addons/auth_totp/models/res_users.py +++ b/addons/auth_totp/models/res_users.py @@ -23,7 +23,7 @@ class Users(models.Model): _inherit = 'res.users' totp_secret = fields.Char(copy=False, groups=fields.NO_ACCESS) - totp_enabled = fields.Boolean(string="TOTP enabled", compute='_compute_totp_enabled') + totp_enabled = fields.Boolean(string="Two-factor authentication", compute='_compute_totp_enabled') def __init__(self, pool, cr): init_res = super().__init__(pool, cr) diff --git a/addons/auth_totp/views/user_preferences.xml b/addons/auth_totp/views/user_preferences.xml index 5bc86194158..004379ddc54 100644 --- a/addons/auth_totp/views/user_preferences.xml +++ b/addons/auth_totp/views/user_preferences.xml @@ -9,6 +9,33 @@ </tree> </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='references']/group[1]" position="before"> + <field name="totp_enabled" invisible="1"/> + <group attrs="{'invisible': [('totp_enabled', '!=', False)]}"> + <div> + <span class="alert alert-info" role="status"> + <i class="fa fa-warning"/> + Two-factor authentication not enabled + </span> + </div> + </group> + <group attrs="{'invisible': [('totp_enabled', '=', False)]}"> + <div> + <span class="text-success"> + <i class="fa fa-check-circle"/> + Two-factor authentication enabled + </span> + </div> + </group> + </xpath> + </field> + </record> + <record model="ir.actions.server" id="action_disable_totp"> <field name="name">Disable TOTP on users</field> <field name="model_id" ref="base.model_res_users"/> |
