Delete the auth data on upgrade from 4.8 if the scope doesn't match

If the user account scope is outdated, delete it when upgrading from 4.8 to 4.9. This means that
the user will have to log in again, to make sure they get the correct account scope.

CURA-8093
This commit is contained in:
Kostas Karmas 2021-04-08 12:46:52 +02:00
parent 1e5d7623cb
commit 72080a3cca
2 changed files with 13 additions and 4 deletions

View file

@ -4,8 +4,10 @@
import configparser
from typing import Tuple, List
import io
import json
from UM.VersionUpgrade import VersionUpgrade
from cura.API import Account
class VersionUpgrade48to49(VersionUpgrade):
@ -32,6 +34,11 @@ class VersionUpgrade48to49(VersionUpgrade):
if "categories_expanded" in parser["cura"] and any([setting in parser["cura"]["categories_expanded"] for setting in self._moved_visibility_settings]):
parser["cura"]["categories_expanded"] += ";top_bottom"
if "ultimaker_auth_data" in parser["general"]:
ultimaker_auth_data = json.loads(parser["general"]["ultimaker_auth_data"])
if set(Account.CLIENT_SCOPES.split(" ")) - set(ultimaker_auth_data["scope"].split(" ")):
parser["general"]["ultimaker_auth_data"] = "{}"
result = io.StringIO()
parser.write(result)
return [filename], [result.getvalue()]