Skip to content

Commit

Permalink
[FIX] some permission problems; call super in order to have regular p…
Browse files Browse the repository at this point in the history
…assword reset flow intact
  • Loading branch information
thomaspaulb committed Dec 3, 2024
1 parent a0518d6 commit cdfcc8f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions auth_sms/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _auth_sms_send(self, user_id):
request and request.session.sid,
)
user = self.env["res.users"].browse(user_id)
self.env["auth_sms.code"].create(
self.env["auth_sms.code"].sudo().create(
{
"code": code,
"user_id": user.id,
Expand All @@ -109,7 +109,8 @@ def _auth_sms_send(self, user_id):
)
if not user.sudo()._auth_sms_check_rate_limit():
raise AccessDeniedSmsRateLimit(_("SMS rate limit"))
if not self.env["sms.provider"].send_sms(user.mobile, code):
mobile = user.sudo().mobile
if not self.env["sms.provider"].send_sms(mobile, code):
raise UserError(_("Sending SMS failed"))

def _auth_sms_check_rate_limit(self):
Expand Down
2 changes: 1 addition & 1 deletion auth_sms/models/sms_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def action_send_test(self):

@api.model
def send_sms(self, number, text, **kwargs):
provider = self.search([], limit=1)
provider = self.sudo().search([], limit=1)
if not provider:
return False
_logger.debug(
Expand Down
4 changes: 2 additions & 2 deletions auth_sms_auth_signup/controllers/auth_sms_auth_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AuthSmsAuthSignup(AuthSignupHome):
def web_auth_reset_password(self, *args, **kw):
qcontext = self.get_auth_signup_qcontext()
if not qcontext.get("token") or qcontext.get("error"):
return super(AuthSmsAuthSignup, self).web_auth_reset_password(*args, **kw)
return super().web_auth_reset_password(*args, **kw)
partner = (
request.env["res.partner"]
.sudo()
Expand All @@ -37,4 +37,4 @@ def web_auth_reset_password(self, *args, **kw):
return super(AuthSmsAuthSignup, self).web_auth_reset_password(
*args, **kw
)
return request.render("auth_signup.reset_password", qcontext)
return super().web_auth_reset_password(*args, **kw)

0 comments on commit cdfcc8f

Please sign in to comment.