Revert "SetupW: Display proper error messages if password or user was wrong."

This reverts commit 396f38598f.

This adds redundant code and potentially breaks Shibboleth
This commit is contained in:
Klaas Freitag 2015-03-10 11:17:35 +01:00
parent 791a0fd01e
commit c88742fad3
6 changed files with 18 additions and 57 deletions

View file

@ -293,12 +293,8 @@ void FolderWizardRemotePath::slotCreateRemoteFolderFinished(QNetworkReply::Netwo
void FolderWizardRemotePath::slotHandleNetworkError(QNetworkReply *reply)
{
qDebug() << "** webdav mkdir request failed:" << reply->error();
if( authenticationFailHappened(reply)) {
showWarn(tr("Authentication failed accessing %1").arg(Theme::instance()->appNameGUI()));
} else {
showWarn(tr("Failed to create the folder on %1. Please check manually.")
.arg(Theme::instance()->appNameGUI()));
}
showWarn(tr("Failed to create the folder on %1. Please check manually.")
.arg(Theme::instance()->appNameGUI()));
}
static QTreeWidgetItem* findFirstChild(QTreeWidgetItem *parent, const QString& text)

View file

@ -245,27 +245,16 @@ bool OwncloudSetupWizard::checkDowngradeAdvised(QNetworkReply* reply)
void OwncloudSetupWizard::slotConnectionCheck(QNetworkReply* reply)
{
QString msg = reply->errorString();
QNetworkReply::NetworkError err = reply->error();
// int errCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
switch (err) {
switch (reply->error()) {
case QNetworkReply::NoError:
case QNetworkReply::ContentNotFoundError:
_ocWizard->successfulStep();
break;
default:
if( authenticationFailHappened(reply) ) {
// if the authentication fails, the request is canceled in HttpCredentials::slotAuthentication
// because of that, we need to check this here.
msg = tr("Credential Error: The entered username or password is wrong.");
} else {
if (!_ocWizard->account()->credentials()->stillValid(reply)) {
msg = tr("Access forbidden by server. To verify that you have proper access, "
"<a href=\"%1\">click here</a> to access the service with your browser.")
.arg(_ocWizard->account()->url().toString());
}
if (!_ocWizard->account()->credentials()->stillValid(reply)) {
msg = tr("Access forbidden by server. To verify that you have proper access, "
"<a href=\"%1\">click here</a> to access the service with your browser.")
.arg(_ocWizard->account()->url().toString());
}
_ocWizard->show();
if (_ocWizard->currentId() == WizardCommon::Page_ShibbolethCreds) {

View file

@ -104,14 +104,8 @@ void ConnectionValidator::slotStatusFound(const QUrl&url, const QVariantMap &inf
// status.php could not be loaded (network or server issue!).
void ConnectionValidator::slotNoStatusFound(QNetworkReply *reply)
{
if( authenticationFailHappened(reply) ) {
// it is an authentication problem, username and password are wrong.
// see HttpCredentials::slotAuthentication
_errors.append(tr("Authentication error: Either username or password are wrong."));
} else {
_errors.append( reply->errorString() );
}
_errors.append(tr("Unable to connect to %1").arg(_account->url().toString()));
_errors.append( reply->errorString() );
reportResult( StatusNotFound );
}

View file

@ -77,6 +77,7 @@ namespace
const char userC[] = "user";
const char certifPathC[] = "certificatePath";
const char certifPasswdC[] = "certificatePasswd";
const char authenticationFailedC[] = "owncloud-authentication-failed";
} // ns
class HttpCredentialsAccessManager : public AccessManager {
@ -246,12 +247,12 @@ void HttpCredentials::fetch()
_readPwdFromDeprecatedPlace = true;
}
}
bool HttpCredentials::stillValid(QNetworkReply *reply)
{
return ((reply->error() != QNetworkReply::AuthenticationRequiredError)
// returned if user or password is incorrect
&& !authenticationFailHappened(reply));
&& (reply->error() != QNetworkReply::OperationCanceledError
|| !reply->property(authenticationFailedC).toBool()));
}
void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
@ -376,7 +377,7 @@ void HttpCredentials::slotAuthentication(QNetworkReply* reply, QAuthenticator* a
// instead of utf8 encoding. Instead, we send it manually. Thus, if we reach this signal,
// those credentials were invalid and we terminate.
qDebug() << "Stop request: Authentication failed for " << reply->url().toString();
setAuthenticationFailed(reply);
reply->setProperty(authenticationFailedC, true);
reply->close();
}

View file

@ -40,6 +40,7 @@ Q_DECLARE_METATYPE(QTimer*)
namespace OCC {
AbstractNetworkJob::AbstractNetworkJob(AccountPtr account, const QString &path, QObject *parent)
: QObject(parent)
, _duration(0)
@ -152,15 +153,13 @@ void AbstractNetworkJob::slotFinished()
{
_timer.stop();
QNetworkReply::NetworkError error = _reply->error();
if( error == QNetworkReply::SslHandshakeFailedError ) {
if( _reply->error() == QNetworkReply::SslHandshakeFailedError ) {
qDebug() << "SslHandshakeFailedError: " << reply()->errorString() << " : can be caused by a webserver wanting SSL client certificates";
}
if( error != QNetworkReply::NoError ) {
qDebug() << Q_FUNC_INFO << error << _reply->errorString();
if (error == QNetworkReply::ProxyAuthenticationRequiredError) {
if( _reply->error() != QNetworkReply::NoError ) {
qDebug() << Q_FUNC_INFO << _reply->error() << _reply->errorString();
if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) {
qDebug() << Q_FUNC_INFO << _reply->rawHeader("Proxy-Authenticate");
}
emit networkError(_reply);
@ -495,20 +494,6 @@ bool LsColJob::finished()
namespace {
const char statusphpC[] = "status.php";
const char owncloudDirC[] = "owncloud/";
const char authenticationFailedC[] = "owncloud-authentication-failed";
}
bool authenticationFailHappened( QNetworkReply *reply )
{
return ( reply && reply->error() == QNetworkReply::OperationCanceledError &&
reply->property(authenticationFailedC).toBool() );
}
void setAuthenticationFailed( QNetworkReply *reply)
{
if( reply ) {
reply->setProperty(authenticationFailedC, true);
}
}
CheckServerJob::CheckServerJob(AccountPtr account, QObject *parent)

View file

@ -32,6 +32,7 @@ namespace OCC {
class AbstractSslErrorHandler;
/**
* @brief Internal Helper class
*/
@ -43,11 +44,6 @@ private:
QPointer<QTimer> _timer;
};
bool OWNCLOUDSYNC_EXPORT authenticationFailHappened( QNetworkReply *reply );
void setAuthenticationFailed( QNetworkReply *reply);
/**
* @brief The AbstractNetworkJob class
*/