| 81 | self._load() |
| 82 | |
| 83 | def _load(self): |
| 84 | if os.path.exists(self._userfile) and os.path.isfile(self._userfile): |
| 85 | self._customized = True |
| 86 | with open(self._userfile, "r") as f: |
| 87 | data = yaml.safe_load(f) |
| 88 | if data: |
| 89 | for name in data.keys(): |
| 90 | attributes = data[name] |
| 91 | apikey = None |
| 92 | publicKey = None |
| 93 | privateKey = None |
| 94 | orgId = None |
| 95 | groupId = None |
| 96 | pin = None |
| 97 | if "apikey" in attributes: |
| 98 | apikey = attributes["apikey"] |
| 99 | if "publicKey" in attributes: |
| 100 | publicKey = attributes['publicKey'] |
| 101 | if 'privateKey' in attributes: |
| 102 | privateKey = attributes['privateKey'] |
| 103 | if 'orgId' in attributes: |
| 104 | orgId = attributes['orgId'] |
| 105 | if 'groupId' in attributes: |
| 106 | groupId = attributes['groupId'] |
| 107 | if 'pin' in attributes: |
| 108 | pin = attributes['pin'] |
| 109 | |
| 110 | self._users[name] = User(name, attributes["password"], attributes["active"], attributes["roles"], publicKey, privateKey, apikey, orgId, groupId, pin) |
| 111 | else: |
| 112 | self._customized = False |
| 113 | |
| 114 | s = settings() |
| 115 | |
| 116 | #Check if loggedUser is still a valid user. If not we remove it |
| 117 | loggedUser = s.get(["cloudSlicer", "loggedUser"]) |
| 118 | if not self.findUser(loggedUser): |
| 119 | s.set(["cloudSlicer", "loggedUser"], None) |
| 120 | s.save() |
| 121 | |
| 122 | def _save(self, force=False): |
| 123 | if not self._dirty and not force: |