mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-12 22:09:25 +08:00
ringaccount: (fix)sets the ringId/username for disabled accounts also
- Commit e57038fe...(ringaccount: sets the ringId/username for disabled accounts also) caused the deviceId to be loaded into ringAccountId_ for disabled accounts. This patch load devices, contacts, and trust requests for disabled accounts while exiting from loadAccount as early as possible. Change-Id: If45ab84ac301faa5776d6af5436e672195c51501
This commit is contained in:
@ -1341,21 +1341,11 @@ RingAccount::loadAccount(const std::string& archive_password, const std::string&
|
||||
if (registrationState_ == RegistrationState::INITIALIZING)
|
||||
return;
|
||||
|
||||
// load identity immediately so we can access the ringIds of disabled accounts
|
||||
auto id = loadIdentity(tlsCertificateFile_, tlsPrivateKeyFile_, tlsPassword_);
|
||||
|
||||
if (not isEnabled()) {
|
||||
if (id.first) {
|
||||
ringAccountId_ = id.first->getPublicKey().getId().toString();
|
||||
username_ = RING_URI_PREFIX + ringAccountId_;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
RING_DBG("[Account %s] loading Ring account", getAccountID().c_str());
|
||||
try {
|
||||
auto id = loadIdentity(tlsCertificateFile_, tlsPrivateKeyFile_, tlsPassword_);
|
||||
bool hasArchive = not archivePath_.empty()
|
||||
and fileutils::isFile(fileutils::getFullPath(idPath_, archivePath_));
|
||||
and fileutils::isFile(fileutils::getFullPath(idPath_, archivePath_));
|
||||
if (useIdentity(id)) {
|
||||
// normal loading path
|
||||
loadKnownDevices();
|
||||
@ -1363,37 +1353,49 @@ RingAccount::loadAccount(const std::string& archive_password, const std::string&
|
||||
loadTrustRequests();
|
||||
if (not hasArchive)
|
||||
RING_WARN("[Account %s] account archive not found, won't be able to add new devices", getAccountID().c_str());
|
||||
} else if (hasArchive) {
|
||||
if (needsMigration(id)) {
|
||||
RING_WARN("[Account %s] account certificate needs update", getAccountID().c_str());
|
||||
migrateAccount(archive_password, id);
|
||||
} else {
|
||||
RING_WARN("[Account %s] archive present but no valid receipt: creating new device", getAccountID().c_str());
|
||||
try {
|
||||
initRingDevice(readArchive(archive_password));
|
||||
} catch (...) {
|
||||
Migration::setState(accountID_, Migration::State::INVALID);
|
||||
return;
|
||||
}
|
||||
Migration::setState(accountID_, Migration::State::SUCCESS);
|
||||
if (not isEnabled()) {
|
||||
setRegistrationState(RegistrationState::UNREGISTERED);
|
||||
}
|
||||
Manager::instance().saveConfig();
|
||||
loadAccount(archive_password);
|
||||
} else {
|
||||
// no receipt or archive, creating new account
|
||||
if (not archive_path.empty()) {
|
||||
// import account from file
|
||||
loadAccountFromFile(archive_path, archive_password);
|
||||
} else if (not archive_pin.empty()) {
|
||||
// import account from DHT
|
||||
loadAccountFromDHT(archive_password, archive_pin);
|
||||
} else {
|
||||
// create new account
|
||||
createAccount(archive_password, std::move(id));
|
||||
}
|
||||
else if (isEnabled()) {
|
||||
if (hasArchive) {
|
||||
if (needsMigration(id)) {
|
||||
RING_WARN("[Account %s] account certificate needs update", getAccountID().c_str());
|
||||
migrateAccount(archive_password, id);
|
||||
}
|
||||
else {
|
||||
RING_WARN("[Account %s] archive present but no valid receipt: creating new device", getAccountID().c_str());
|
||||
try {
|
||||
initRingDevice(readArchive(archive_password));
|
||||
}
|
||||
catch (...) {
|
||||
Migration::setState(accountID_, Migration::State::INVALID);
|
||||
return;
|
||||
}
|
||||
Migration::setState(accountID_, Migration::State::SUCCESS);
|
||||
setRegistrationState(RegistrationState::UNREGISTERED);
|
||||
}
|
||||
Manager::instance().saveConfig();
|
||||
loadAccount(archive_password);
|
||||
}
|
||||
else {
|
||||
// no receipt or archive, creating new account
|
||||
if (not archive_path.empty()) {
|
||||
// import account from file
|
||||
loadAccountFromFile(archive_path, archive_password);
|
||||
}
|
||||
else if (not archive_pin.empty()) {
|
||||
// import account from DHT
|
||||
loadAccountFromDHT(archive_password, archive_pin);
|
||||
}
|
||||
else {
|
||||
// create new account
|
||||
createAccount(archive_password, std::move(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
RING_WARN("[Account %s] error loading account: %s", getAccountID().c_str(), e.what());
|
||||
identity_ = dht::crypto::Identity{};
|
||||
setRegistrationState(RegistrationState::ERROR_GENERIC);
|
||||
@ -3282,3 +3284,4 @@ RingAccount::registerDhtAddress(IceTransport& ice)
|
||||
}
|
||||
|
||||
} // namespace ring
|
||||
|
||||
|
Reference in New Issue
Block a user