mirror of
https://github.com/bringout/oca-ocb-security.git
synced 2026-04-23 10:52:06 +02:00
19.0 vanilla
This commit is contained in:
parent
20ddc1b4a3
commit
c0efcc53f5
1162 changed files with 125577 additions and 105287 deletions
|
|
@ -17,7 +17,8 @@ from odoo.addons.auth_totp.models.totp import ALGORITHM, DIGITS, TIMESTEP
|
|||
|
||||
compress = functools.partial(re.sub, r'\s', '')
|
||||
|
||||
class TOTPWizard(models.TransientModel):
|
||||
|
||||
class Auth_TotpWizard(models.TransientModel):
|
||||
_name = 'auth_totp.wizard'
|
||||
_description = "2-Factor Setup Wizard"
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ class TOTPWizard(models.TransientModel):
|
|||
attachment=False, store=True, readonly=True,
|
||||
compute='_compute_qrcode',
|
||||
)
|
||||
code = fields.Char(string="Verification Code", size=7)
|
||||
code = fields.Char(string="Verification Code", size=7, store=False)
|
||||
|
||||
@api.depends('user_id.login', 'user_id.company_id.display_name', 'secret')
|
||||
def _compute_qrcode(self):
|
||||
|
|
@ -57,7 +58,7 @@ class TOTPWizard(models.TransientModel):
|
|||
@check_identity
|
||||
def enable(self):
|
||||
try:
|
||||
c = int(compress(self.code))
|
||||
c = int(compress(self.env.context.get('code', '')))
|
||||
except ValueError:
|
||||
raise UserError(_("The verification code should only contain numbers"))
|
||||
if self.user_id._totp_try_setting(self.secret, c):
|
||||
|
|
@ -72,9 +73,3 @@ class TOTPWizard(models.TransientModel):
|
|||
}
|
||||
}
|
||||
raise UserError(_('Verification failed, please double-check the 6-digit code'))
|
||||
|
||||
def create(self, vals_list):
|
||||
rule = self.env.ref('auth_totp.rule_auth_totp_wizard', raise_if_not_found=False)
|
||||
if rule and rule.sudo().groups:
|
||||
rule.sudo().groups = False
|
||||
return super().create(vals_list)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue