Files
session_redis_public/session_redis/models/user.py
T
Yannick Vaucher 697f5ae58f Fix session check crash due to odoo recent change [1]
Odoo introduced a token on 2018-03-19, this token is
used for checking the rights.

The token itself is generated from data as a hash.
The redis_session module handle it correctly by saving it aside other
data in json format. Nevertheless, when reading it, from json format,
it forces all strings to unicode whereas some dumped string where str.

Thus it fails on comparison between str and unicode.

This fix solves it by always using token in unicode format.

[1] https://github.com/odoo/odoo/pull/22612
2018-04-05 18:57:31 +02:00

20 lines
638 B
Python

from odoo import models, tools
class User(models.Model):
_inherit = 'res.users'
@tools.ormcache('sid')
def _compute_session_token(self, sid):
"""Make sure to return an unicode string.
Odoo creates a session token using hexdigest Session which is str
but with redis we set the token from a dictionary of values passing
it in json format. When dumping values from json, we always get unicode
thus both are incompatible.
The shortest path is to fix the output of the computed session by Odoo.
"""
return unicode(super(User, self)._compute_session_token(sid))