Skip to content

Commit 19be1fc

Browse files
ilyas caluwealexis-via
authored andcommitted
[MIG] password_security: Migration to 17.0
1 parent a858641 commit 19be1fc

File tree

6 files changed

+46
-95
lines changed

6 files changed

+46
-95
lines changed

password_security/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{
66
"name": "Password Security",
77
"summary": "Allow admin to set password security requirements.",
8-
"version": "16.0.1.0.0",
8+
"version": "17.0.1.0.0",
99
"author": "LasLabs, "
1010
"Onestein, "
1111
"Kaushal Prajapati, "

password_security/controllers/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ def do_signup(self, qcontext):
1919
password = qcontext.get("password")
2020
user = request.env.user
2121
user._check_password(password)
22-
return super(PasswordSecurityHome, self).do_signup(qcontext)
22+
return super().do_signup(qcontext)
2323

2424
@http.route()
2525
def web_login(self, *args, **kw):
2626
ensure_db()
27-
response = super(PasswordSecurityHome, self).web_login(*args, **kw)
27+
response = super().web_login(*args, **kw)
2828
if not request.params.get("login_success"):
2929
return response
3030
if not request.env.user:
@@ -50,7 +50,7 @@ def web_auth_signup(self, *args, **kw):
5050
raise BadRequest from None # HTTPError: 400 Client Error: BAD REQUEST
5151

5252
try:
53-
return super(PasswordSecurityHome, self).web_auth_signup(*args, **kw)
53+
return super().web_auth_signup(*args, **kw)
5454
except Exception as e:
5555
# Here we catch any generic exception since UserError is already
5656
# handled in parent method web_auth_signup()

password_security/migrations/16.0.1.0.0/pre-migration.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

password_security/models/res_users.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class ResUsers(models.Model):
3030
def write(self, vals):
3131
if vals.get("password"):
3232
vals["password_write_date"] = fields.Datetime.now()
33-
return super(ResUsers, self).write(vals)
33+
return super().write(vals)
3434

3535
@api.model
3636
def get_password_policy(self):
37-
data = super(ResUsers, self).get_password_policy()
37+
data = super().get_password_policy()
3838
company_id = self.env.user.company_id
3939
data.update(
4040
{
@@ -47,7 +47,7 @@ def get_password_policy(self):
4747
return data
4848

4949
def _check_password_policy(self, passwords):
50-
result = super(ResUsers, self)._check_password_policy(passwords)
50+
result = super()._check_password_policy(passwords)
5151

5252
for password in passwords:
5353
if not password:
@@ -178,7 +178,7 @@ def _check_password_history(self, password):
178178

179179
def _set_encrypted_password(self, uid, pw):
180180
"""It saves password crypt history for history rules"""
181-
res = super(ResUsers, self)._set_encrypted_password(uid, pw)
181+
res = super()._set_encrypted_password(uid, pw)
182182

183183
self.env["res.users.pass.history"].create(
184184
{
@@ -196,4 +196,4 @@ def action_reset_password(self):
196196
if not self.env.user._is_admin():
197197
users = self.filtered(lambda user: user.active)
198198
users._validate_pass_reset()
199-
return super(ResUsers, self).action_reset_password()
199+
return super().action_reset_password()

password_security/tests/test_res_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class TestResUsers(TransactionCase):
1111
def setUp(self):
12-
super(TestResUsers, self).setUp()
12+
super().setUp()
1313
self.login = "[email protected]"
1414
self.partner_vals = {
1515
"name": "Partner",

password_security/views/res_config_settings_views.xml

Lines changed: 36 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,27 @@
1212
ref="auth_password_policy.res_config_settings_view_form"
1313
/>
1414
<field name="arch" type="xml">
15-
<!-- Hide label for uniform styling -->
16-
<xpath expr="//label[@for='minlength']" position="attributes">
17-
<attribute name="invisible">1</attribute>
18-
</xpath>
19-
20-
<!-- Add an id for easier lookup -->
21-
<xpath
22-
expr="//field[@name='minlength']/ancestor::div[hasclass('o_setting_box')]"
23-
position="attributes"
24-
>
25-
<attribute name="id">password_policy</attribute>
26-
</xpath>
27-
28-
<!-- Move the settings box to desired location -->
29-
<xpath expr="//div[@id='enable_password_reset']" position="after">
30-
<xpath expr="//div[@id='password_policy']" position="move" />
31-
</xpath>
32-
3315
<!-- Ensure our settings will come after any former customization -->
34-
<xpath
35-
expr="//div[@id='password_policy']//div[hasclass('o_setting_right_pane')]/*"
36-
position="after"
37-
>
38-
<label string="Password Policy" for="password_expiration" />
39-
<div class="content-group">
40-
<div class="mt16">
16+
<xpath expr="//block[@id='user_default_rights']" position="after">
17+
<block title="Password Policy" id="password_policy">
18+
<setting>
4119
<span>
42-
Password expires in
43-
<field name="password_expiration" class="oe_inline" />
44-
days.
20+
Password expires in <field
21+
name="password_expiration"
22+
class="oe_inline"
23+
/> days.
4524
</span>
46-
</div>
47-
<div class="mt16">
25+
</setting>
26+
<setting>
4827
<span>
49-
User can change password in
50-
<field name="password_minimum" class="oe_inline" />
51-
hours again.
28+
User can change password in <field
29+
name="password_minimum"
30+
class="oe_inline"
31+
/> hours again.
5232
</span>
53-
</div>
54-
<div class="mt16">
33+
</setting>
34+
35+
<setting>
5536
<span>
5637
Disallow reuse of
5738
<field name="password_history" class="oe_inline" />
@@ -60,47 +41,41 @@
6041
<div class="text-muted">
6142
Use negative number for infinite, or 0 to disable
6243
</div>
63-
</div>
64-
<div class="mt16">
44+
</setting>
45+
<setting>
6546
<span>
6647
Minimum number of lowercase characters
67-
<field name="password_lower" class="oe_inline" />
48+
<field name="password_lower" />
6849
</span>
69-
</div>
70-
<div class="mt16">
50+
</setting>
51+
<setting>
7152
<span>
7253
Minimum number of uppercase characters
73-
<field name="password_upper" class="oe_inline" />
54+
<field name="password_upper" />
7455
</span>
75-
</div>
76-
<div class="mt16">
56+
</setting>
57+
<setting>
7758
<span>
7859
Minimum number of numeric characters
79-
<field name="password_numeric" class="oe_inline" />
60+
<field name="password_numeric" />
8061
</span>
81-
</div>
82-
<div class="mt16">
62+
</setting>
63+
<setting>
8364
<span>
8465
Minimum number of special characters
85-
<field name="password_special" class="oe_inline" />
66+
<field name="password_special" />
8667
</span>
87-
</div>
88-
<div class="mt16">
89-
<span id="minlength">
90-
Minimum number of characters
91-
</span>
92-
</div>
93-
</div>
94-
</xpath>
95-
96-
<!-- Add oe_inline attribute to minlength -->
97-
<xpath expr="//field[@name='minlength']" position="attributes">
98-
<attribute name="class">oe_inline</attribute>
68+
</setting>
69+
</block>
9970
</xpath>
10071

10172
<!-- Move the minlength field to desired location -->
102-
<xpath expr="//span[@id='minlength']" position="inside">
103-
<xpath expr="//field[@name='minlength']" position="move" />
73+
<xpath expr="//block[@id='password_policy']" position="inside">
74+
<xpath expr="//field[@name='minlength']/.." position="move" />
75+
<xpath
76+
expr="//field[@name='auth_signup_reset_password']/.."
77+
position="move"
78+
/>
10479
</xpath>
10580
</field>
10681
</record>

0 commit comments

Comments
 (0)