Fix credentialstore on startup, promote credentials back on setup.

This fixes https://github.com/owncloud/mirall/issues/81
This commit is contained in:
Klaas Freitag 2012-11-15 11:42:49 +01:00
parent c5739b4d53
commit 01e8c9dbbe
4 changed files with 21 additions and 3 deletions

View File

@ -144,4 +144,11 @@ QByteArray CredentialStore::basicAuthHeader() const
return data;
}
void CredentialStore::setCredentials( const QString& user, const QString& pwd )
{
_passwd = pwd;
_user = user;
_state = Ok;
}
}

View File

@ -72,6 +72,16 @@ public:
* @return the singleton pointer to access the object.
*/
static CredentialStore *instance();
/**
* @brief setCredentials - sets the user credentials.
*
* This function is called from the setup wizard to set the credentials
* int this store. The function also sets the state to ok.
* @param user - the user name
* @param password - the password.
*/
void setCredentials( const QString&, const QString& );
signals:
/**
* @brief fetchCredentialsFinished

View File

@ -17,6 +17,7 @@
#include "mirall/mirallconfigfile.h"
#include "mirall/owncloudtheme.h"
#include "mirall/miralltheme.h"
#include "mirall/credentialstore.h"
#include <QtCore>
#include <QtGui>
@ -29,7 +30,6 @@
namespace Mirall {
QString MirallConfigFile::_passwd;
QString MirallConfigFile::_oCVersion;
bool MirallConfigFile::_askedUser = false;
@ -151,10 +151,12 @@ void MirallConfigFile::writeOwncloudConfig( const QString& connection,
settings.setValue( QLatin1String("passwd"), QVariant(pwdba.toBase64()) );
settings.setValue( QLatin1String("nostoredpassword"), QVariant(skipPwd) );
settings.sync();
// check the perms, only read-write for the owner.
QFile::setPermissions( file, QFile::ReadOwner|QFile::WriteOwner );
// inform the credential store about the password change.
CredentialStore::instance()->setCredentials( user, pwd );
}
// set the url, called from redirect handling.

View File

@ -113,7 +113,6 @@ private:
private:
static QString _passwd;
static bool _askedUser;
static QString _oCVersion;
QString _customHandle;