Commit bec28a94 authored by Shashwat Jolly's avatar Shashwat Jolly
Browse files

Fix account initialisation bug

parent 1e5cbee8
......@@ -56,7 +56,7 @@ void EteSyncClientState::init()
EteSyncUserInfoManagerPtr userInfoManager(etesync_user_info_manager_new(mClient.get()));
mUserInfo = etesync_user_info_manager_fetch(userInfoManager.get(), mUsername);
if (!mUserInfo) {
qCWarning(ETESYNC_LOG) << "User info obtained from server is NULL";
qCWarning(ETESYNC_LOG) << "init() - User info obtained from server is NULL";
invalidateToken();
Q_EMIT clientInitialised(false);
return;
......@@ -104,9 +104,8 @@ bool EteSyncClientState::initUserInfo()
EteSyncUserInfoManagerPtr userInfoManager(etesync_user_info_manager_new(mClient.get()));
mUserInfo = etesync_user_info_manager_fetch(userInfoManager.get(), mUsername);
if (!mUserInfo) {
qCWarning(ETESYNC_LOG) << "User info obtained from server is NULL";
qCWarning(ETESYNC_LOG) << "initUserInfo() - User info obtained from server is NULL";
qCDebug(ETESYNC_LOG) << "EteSync error" << QStringFromCharPtr(CharPtr(etesync_get_error_message()));
invalidateToken();
return false;
}
return true;
......@@ -142,7 +141,7 @@ void EteSyncClientState::initAccount(const QString &encryptionPassword)
EteSyncCryptoManagerPtr userInfoCryptoManager = etesync_user_info_get_crypto_manager(mUserInfo.get(), mDerived);
etesync_user_info_set_keypair(mUserInfo.get(), userInfoCryptoManager.get(), mKeypair.get());
EteSyncUserInfoManagerPtr userInfoManager(etesync_user_info_manager_new(mClient.get()));
if (!etesync_user_info_manager_create(userInfoManager.get(), mUserInfo.get())) {
if (etesync_user_info_manager_create(userInfoManager.get(), mUserInfo.get())) {
qCDebug(ETESYNC_LOG) << "Could not create user info";
qCDebug(ETESYNC_LOG) << "EteSync error" << QStringFromCharPtr(CharPtr(etesync_get_error_message()));
return;
......
......@@ -86,7 +86,12 @@ bool LoginPage::validatePage()
const QString serverUrl = advancedServerUrl.isEmpty() ? QStringLiteral("https://api.etesync.com") : advancedServerUrl;
const bool loginResult = static_cast<SetupWizard *>(wizard())->mClientState->initToken(serverUrl, username, password);
if (!loginResult) {
mLoginLabel->setText(i18n("Incorrect login credentials. Please try again."));
qCDebug(ETESYNC_LOG) << "EteSync error" << QStringFromCharPtr(CharPtr(etesync_get_error_message()));
if (etesync_get_error_code() == EteSyncErrorCode::ETESYNC_ERROR_CODE_UNAUTHORIZED) {
mLoginLabel->setText(i18n("Incorrect login credentials. Please try again."));
} else {
mLoginLabel->setText(i18n(etesync_get_error_message()));
}
}
return loginResult;
}
......@@ -117,8 +122,13 @@ void EncryptionPasswordPage::initializePage()
{
const bool userInfoResult = static_cast<SetupWizard *>(wizard())->mClientState->initUserInfo();
if (!userInfoResult) {
setSubTitle(i18n("Please set your encryption password below, and make sure you got it right, as it can't be recovered if lost!"));
mInitAccount = true;
if (etesync_get_error_code() == EteSyncErrorCode::ETESYNC_ERROR_CODE_NOT_FOUND) {
setSubTitle(i18n("Please set your encryption password below, and make sure you got it right, as it can't be recovered if lost!"));
mInitAccount = true;
} else {
qCDebug(ETESYNC_LOG) << "EteSync error" << QStringFromCharPtr(CharPtr(etesync_get_error_message()));
setSubTitle(i18n("An error occured! Please try again."));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment