mirror of
https://github.com/bringout/oca-ocb-security.git
synced 2026-04-23 11:32:05 +02:00
Initial commit: Security packages
This commit is contained in:
commit
bb469e4763
1399 changed files with 278378 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import res_users
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import _, models
|
||||
|
||||
|
||||
class Users(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
def action_open_my_account_settings(self):
|
||||
action = {
|
||||
"name": _("Account Security"),
|
||||
"type": "ir.actions.act_window",
|
||||
"res_model": "res.users",
|
||||
"views": [[self.env.ref('auth_totp_mail.res_users_view_form').id, "form"]],
|
||||
"res_id": self.id,
|
||||
}
|
||||
return action
|
||||
|
||||
def get_totp_invite_url(self):
|
||||
return '/web#action=auth_totp_mail.action_activate_two_factor_authentication'
|
||||
|
||||
def action_totp_invite(self):
|
||||
invite_template = self.env.ref('auth_totp_mail.mail_template_totp_invite')
|
||||
users_to_invite = self.sudo().filtered(lambda user: not user.totp_secret)
|
||||
for user in users_to_invite:
|
||||
email_values = {
|
||||
'email_from': self.env.user.email_formatted,
|
||||
'author_id': self.env.user.partner_id.id,
|
||||
}
|
||||
invite_template.send_mail(user.id, force_send=True, email_values=email_values,
|
||||
email_layout_xmlid='mail.mail_notification_light')
|
||||
|
||||
# Display a confirmation toaster
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'params': {
|
||||
'type': 'info',
|
||||
'sticky': False,
|
||||
'message': _("Invitation to use two-factor authentication sent for the following user(s): %s",
|
||||
', '.join(users_to_invite.mapped('name'))),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue