account: check if password is valid

Change-Id: Ice7459ba421c28f72c05bfda5283b733acef4695
This commit is contained in:
Kateryna Kostiuk
2020-05-15 14:17:42 -04:00
parent 5e4f17ea8a
commit bcc75c7fd1
9 changed files with 41 additions and 1 deletions

View File

@ -251,6 +251,12 @@ sendRegister(const std::string& accountID, bool enable)
jami::Manager::instance().sendRegister(accountID, enable);
}
bool
isPasswordValid(const std::string& accountID, const std::string& password)
{
return jami::Manager::instance().isPasswordValid(accountID, password);
}
void
registerAllAccounts()
{

View File

@ -65,6 +65,7 @@ DRING_PUBLIC bool exportToFile(const std::string& accountID, const std::string&
DRING_PUBLIC bool revokeDevice(const std::string& accountID, const std::string& password, const std::string& deviceID);
DRING_PUBLIC std::map<std::string, std::string> getKnownRingDevices(const std::string& accountID);
DRING_PUBLIC bool changeAccountPassword(const std::string& accountID, const std::string& password_old, const std::string& password_new);
DRING_PUBLIC bool isPasswordValid(const std::string& accountID, const std::string& password);
DRING_PUBLIC bool lookupName(const std::string& account, const std::string& nameserver, const std::string& name);
DRING_PUBLIC bool lookupAddress(const std::string& account, const std::string& nameserver, const std::string& address);

View File

@ -121,6 +121,8 @@ public:
virtual void syncDevices() = 0;
virtual bool isPasswordValid(const std::string& password) {};
dht::crypto::Identity loadIdentity(const std::string& crt_path, const std::string& key_path, const std::string& key_pwd) const;
const AccountInfo* useIdentity(

View File

@ -673,6 +673,17 @@ ArchiveAccountManager::exportArchive(const std::string& destinationPath, const s
}
}
bool
ArchiveAccountManager::isPasswordValid(const std::string& password)
{
try {
readArchive(password);
return true;
} catch (...) {
return false;
}
}
#if HAVE_RINGNS
void

View File

@ -60,6 +60,7 @@ public:
void addDevice(const std::string& password, AddDeviceCallback) override;
bool revokeDevice(const std::string& password, const std::string& device, RevokeDeviceCallback) override;
bool exportArchive(const std::string& destinationPath, const std::string& password);
bool isPasswordValid(const std::string& password) override;
#if HAVE_RINGNS
/*void lookupName(const std::string& name, LookupCallback cb) override;
@ -97,4 +98,4 @@ private:
std::string archivePath_;
};
}
}

View File

@ -971,6 +971,12 @@ JamiAccount::changeArchivePassword(const std::string& password_old, const std::s
return true;
}
bool
JamiAccount::isPasswordValid(const std::string& password)
{
return accountManager_->isPasswordValid(password);
}
void
JamiAccount::addDevice(const std::string& password)
{

View File

@ -331,6 +331,8 @@ public:
bool revokeDevice(const std::string& password, const std::string& device);
std::map<std::string, std::string> getKnownDevices() const;
bool isPasswordValid(const std::string& password);
bool changeArchivePassword(const std::string& password_old, const std::string& password_new);
void connectivityChanged() override;

View File

@ -2933,6 +2933,15 @@ Manager::sendRegister(const std::string& accountID, bool enable)
acc->doUnregister();
}
bool
Manager::isPasswordValid(const std::string& accountID, const std::string& password)
{
const auto acc = getAccount<JamiAccount>(accountID);
if (!acc)
return false;
return acc->isPasswordValid(password);
}
uint64_t
Manager::sendTextMessage(const std::string& accountID, const std::string& to,
const std::map<std::string, std::string>& payloads)

View File

@ -388,6 +388,8 @@ class DRING_TESTABLE Manager {
*/
void sendRegister(const std::string& accountId, bool enable);
bool isPasswordValid(const std::string& accountID, const std::string& password);
uint64_t sendTextMessage(const std::string& accountID, const std::string& to,
const std::map<std::string, std::string>& payloads);