The token is `str` in PyJWT >= 2 and Python3. Check `controllers/auth.py` where the same code is used.
Fixes: https://tracker.ceph.com/issues/59689
References: https://github.com/SUSE/ceph/pull/506
Signed-off-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit
0fc6e7637657a96acfb0aa01dde6b3fbd81a136d)
token = JwtManager.gen_token(username)
JwtManager.set_user(JwtManager.decode_token(token))
- token = token.decode('utf-8')
+
+ # For backward-compatibility: PyJWT versions < 2.0.0 return bytes.
+ token = token.decode('utf-8') if isinstance(token, bytes) else token
+
self._set_token_cookie(url_prefix, token)
raise cherrypy.HTTPRedirect("{}/#/login?access_token={}".format(url_prefix, token))