Skip to Content
Menu
This question has been flagged
1 Reply
1265 Views

403: Forbidden

The page you were looking for could not be authorized.


Odoo V16 any idea how to resolve


Traceback (most recent call last):
  File "/opt/odoo/odoo/odoo/http.py", line 1583, in _serve_db
    return service_model.retrying(self._serve_ir_http, self.env)
  File "/opt/odoo/odoo/odoo/service/model.py", line 134, in retrying
    result = func()
  File "/opt/odoo/odoo/odoo/http.py", line 1610, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "/opt/odoo/odoo/odoo/http.py", line 1723, in dispatch
    return self.request.registry['ir.http']._dispatch(endpoint)
  File "/opt/odoo/odoo/addons/website/models/ir_http.py", line 235, in _dispatch
    response = super()._dispatch(endpoint)
  File "/opt/odoo/odoo/odoo/addons/base/models/ir_http.py", line 154, in _dispatch
    result = endpoint(**request.params)
  File "/opt/odoo/odoo/odoo/http.py", line 696, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "/opt/odoo/odoo/addons/mass_mailing/controllers/main.py", line 36, in mailing
    raise exceptions.AccessDenied()
odoo.exceptions.AccessDenied: Access Denied


Avatar
Discard

As already mentioned by Jort, this is a typical message when testing email marketing, because when testing, Links are not yet generated.

Best Answer

Did you get this message when sending a test mail? What value does res_id have in the url? When this value equals 0 it means that it is not linked to a medium_id in the database. This happens when you send a test email. You could try to create test mailing with a mailing list that includes your test email address only and send this one. You should now be able to use the unsubscribe link.


@http.route(['/mail/mailing//unsubscribe'], type='http', website=True, auth='public')
def mailing(self, mailing_id, email=None, res_id=None, token="", **post):
    mailing = request.env['mailing.mailing'].sudo().browse(mailing_id)
    if mailing.exists():
        res_id = res_id and int(res_id)
        if not self._valid_unsubscribe_token(mailing_id, res_id, email, str(token)):
            raise exceptions.AccessDenied()

def _valid_unsubscribe_token(self, mailing_id, res_id, email, token):
    if not (mailing_id and res_id and email and token):
        return False
    mailing = request.env['mailing.mailing'].sudo().browse(mailing_id)
    return consteq(mailing._unsubscribe_token(res_id, email), token)

def _unsubscribe_token(self, res_id, email):
    """Generate a secure hash for this mailing list and parameters.

    This is appended to the unsubscription URL and then checked at
    unsubscription time to ensure no malicious unsubscriptions are
    performed.

    :param int res_id:
        ID of the resource that will be unsubscribed.

    :param str email:
        Email of the resource that will be unsubscribed.
    """
    secret = self.env["ir.config_parameter"].sudo().get_param("database.secret")
    token = (self.env.cr.dbname, self.id, int(res_id), tools.ustr(email))
    return hmac.new(secret.encode('utf-8'), repr(token).encode('utf-8'), hashlib.sha512).hexdigest()

This is the code that raises the AccessDenied exeption from the mass_mailing controller and model.

I hope this helps!

Avatar
Discard
Related Posts Replies Views Activity
0
Dec 22
1728
2
Apr 25
3957
0
May 23
3095
1
Oct 22
2792
4
Jun 19
4708