diff --git a/libnymea-remoteproxy/authentication/authenticationprocess.cpp b/libnymea-remoteproxy/authentication/authenticationprocess.cpp index 3f5eea3..13f2c6b 100644 --- a/libnymea-remoteproxy/authentication/authenticationprocess.cpp +++ b/libnymea-remoteproxy/authentication/authenticationprocess.cpp @@ -1,6 +1,5 @@ #include "authenticationprocess.h" #include "loggingcategories.h" -#include "userinformation.h" #include #include @@ -163,7 +162,7 @@ void AuthenticationProcess::onProcessFinished(int exitCode, QProcess::ExitStatus UserInformation userInformation(email, cognitoUsername, vendorId, userPoolId); - emit authenticationFinished(Authenticator::AuthenticationErrorNoError); + emit authenticationFinished(Authenticator::AuthenticationErrorNoError, userInformation); } else { emit authenticationFinished(Authenticator::AuthenticationErrorAuthenticationFailed); } diff --git a/libnymea-remoteproxy/authentication/authenticationprocess.h b/libnymea-remoteproxy/authentication/authenticationprocess.h index 0ac7ccc..b5ecd96 100644 --- a/libnymea-remoteproxy/authentication/authenticationprocess.h +++ b/libnymea-remoteproxy/authentication/authenticationprocess.h @@ -7,6 +7,7 @@ #include #include "authenticator.h" +#include "userinformation.h" namespace remoteproxy { @@ -37,7 +38,7 @@ private: void cleanUp(); signals: - void authenticationFinished(Authenticator::AuthenticationError error); + void authenticationFinished(Authenticator::AuthenticationError error, const UserInformation &userInformation = UserInformation()); private slots: void onDynamicCredentialsReady(); diff --git a/libnymea-remoteproxy/authentication/awsauthenticator.cpp b/libnymea-remoteproxy/authentication/awsauthenticator.cpp index 2ca3870..cc76bc2 100644 --- a/libnymea-remoteproxy/authentication/awsauthenticator.cpp +++ b/libnymea-remoteproxy/authentication/awsauthenticator.cpp @@ -22,20 +22,24 @@ QString AwsAuthenticator::name() const return "AWS authenticator"; } -void AwsAuthenticator::onAuthenticationProcessFinished(Authenticator::AuthenticationError error) +void AwsAuthenticator::onAuthenticationProcessFinished(Authenticator::AuthenticationError error, const UserInformation &userInformation) { AuthenticationProcess *process = static_cast(sender()); AuthenticationReply *reply = m_runningProcesses.take(process); + if (error == AuthenticationErrorNoError) { + qCDebug(dcAuthentication()) << name() << reply->proxyClient() << "finished successfully." << userInformation; + } else { + qCDebug(dcAuthentication()) << name() << reply->proxyClient() << "finished with error" << error; + } + setReplyError(reply, error); setReplyFinished(reply); - - qCDebug(dcAuthentication()) << name() << "finished with error" << error; } AuthenticationReply *AwsAuthenticator::authenticate(ProxyClient *proxyClient) { - qCDebug(dcAuthentication()) << name() << "Start authenticating" << proxyClient << "using token" << proxyClient->token(); + qCDebug(dcAuthentication()) << name() << "Start authenticating" << proxyClient; AuthenticationReply *reply = createAuthenticationReply(proxyClient, this); AuthenticationProcess *process = new AuthenticationProcess(m_manager, this); diff --git a/libnymea-remoteproxy/authentication/awsauthenticator.h b/libnymea-remoteproxy/authentication/awsauthenticator.h index ca7cdcf..19b3313 100644 --- a/libnymea-remoteproxy/authentication/awsauthenticator.h +++ b/libnymea-remoteproxy/authentication/awsauthenticator.h @@ -24,7 +24,7 @@ private: QHash m_runningProcesses; private slots: - void onAuthenticationProcessFinished(Authenticator::AuthenticationError error); + void onAuthenticationProcessFinished(Authenticator::AuthenticationError error, const UserInformation &userInformation); public slots: AuthenticationReply *authenticate(ProxyClient *proxyClient) override; diff --git a/libnymea-remoteproxy/authentication/userinformation.cpp b/libnymea-remoteproxy/authentication/userinformation.cpp index 2dde27d..07c14c6 100644 --- a/libnymea-remoteproxy/authentication/userinformation.cpp +++ b/libnymea-remoteproxy/authentication/userinformation.cpp @@ -39,4 +39,13 @@ bool UserInformation::isValid() && !m_userPoolId.isEmpty(); } +QDebug operator<<(QDebug debug, const UserInformation &userInformation) +{ + debug.nospace() << "UserInformation(" << userInformation.email(); + debug.nospace() << ", cognito:" << userInformation.cognitoUsername() << ") "; + debug.nospace() << ", vendor" << userInformation.vendorId() << ") "; + debug.nospace() << ", userpool" << userInformation.userPoolId() << ") "; + return debug; +} + } diff --git a/libnymea-remoteproxy/authentication/userinformation.h b/libnymea-remoteproxy/authentication/userinformation.h index 0e32ae8..c6d71fa 100644 --- a/libnymea-remoteproxy/authentication/userinformation.h +++ b/libnymea-remoteproxy/authentication/userinformation.h @@ -1,6 +1,7 @@ #ifndef USERINFORMATION_H #define USERINFORMATION_H +#include #include namespace remoteproxy { @@ -25,6 +26,8 @@ private: QString m_userPoolId; }; +QDebug operator<<(QDebug debug, const UserInformation &userInformation); + } #endif // USERINFORMATION_H