mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 07:36:44 +00:00
fix(GODT-2778): fix login screen being disabled after an 'already logged in' error.
This commit is contained in:
@ -385,6 +385,14 @@ Status GRPCService::Login(ServerContext *, LoginRequest const *request, Empty *)
|
|||||||
app().log().debug(__FUNCTION__);
|
app().log().debug(__FUNCTION__);
|
||||||
UsersTab &usersTab = app().mainWindow().usersTab();
|
UsersTab &usersTab = app().mainWindow().usersTab();
|
||||||
loginUsername_ = QString::fromStdString(request->username());
|
loginUsername_ = QString::fromStdString(request->username());
|
||||||
|
|
||||||
|
SPUser const& user = usersTab.userTable().userWithUsernameOrEmail(QString::fromStdString(request->username()));
|
||||||
|
if (user) {
|
||||||
|
qtProxy_.sendDelayedEvent(newLoginAlreadyLoggedInEvent(user->id()));
|
||||||
|
return Status::OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (usersTab.nextUserUsernamePasswordError()) {
|
if (usersTab.nextUserUsernamePasswordError()) {
|
||||||
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::USERNAME_PASSWORD_ERROR, usersTab.usernamePasswordErrorMessage()));
|
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::USERNAME_PASSWORD_ERROR, usersTab.usernamePasswordErrorMessage()));
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
@ -826,7 +834,7 @@ bool GRPCService::sendEvent(SPStreamEvent const &event) {
|
|||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
void GRPCService::finishLogin() {
|
void GRPCService::finishLogin() {
|
||||||
UsersTab &usersTab = app().mainWindow().usersTab();
|
UsersTab &usersTab = app().mainWindow().usersTab();
|
||||||
SPUser user = usersTab.userWithUsername(loginUsername_);
|
SPUser user = usersTab.userWithUsernameOrEmail(loginUsername_);
|
||||||
bool const alreadyExist = user.get();
|
bool const alreadyExist = user.get();
|
||||||
if (!user) {
|
if (!user) {
|
||||||
user = randomUser();
|
user = randomUser();
|
||||||
|
|||||||
@ -272,8 +272,8 @@ bridgepp::SPUser UsersTab::userWithID(QString const &userID) {
|
|||||||
/// \return The user with the given username.
|
/// \return The user with the given username.
|
||||||
/// \return A null pointer if the user is not in the list.
|
/// \return A null pointer if the user is not in the list.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
bridgepp::SPUser UsersTab::userWithUsername(QString const &username) {
|
bridgepp::SPUser UsersTab::userWithUsernameOrEmail(QString const &username) {
|
||||||
return users_.userWithUsername(username);
|
return users_.userWithUsernameOrEmail(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public: // member functions.
|
|||||||
UsersTab &operator=(UsersTab &&) = delete; ///< Disabled move assignment operator.
|
UsersTab &operator=(UsersTab &&) = delete; ///< Disabled move assignment operator.
|
||||||
UserTable &userTable(); ///< Returns a reference to the user table.
|
UserTable &userTable(); ///< Returns a reference to the user table.
|
||||||
bridgepp::SPUser userWithID(QString const &userID); ///< Get the user with the given ID.
|
bridgepp::SPUser userWithID(QString const &userID); ///< Get the user with the given ID.
|
||||||
bridgepp::SPUser userWithUsername(QString const &username); ///< Get the user with the given username.
|
bridgepp::SPUser userWithUsernameOrEmail(QString const &username); ///< Get the user with the given username.
|
||||||
bool nextUserUsernamePasswordError() const; ///< Check if next user login should trigger a username/password error.
|
bool nextUserUsernamePasswordError() const; ///< Check if next user login should trigger a username/password error.
|
||||||
bool nextUserFreeUserError() const; ///< Check if next user login should trigger a Free user error.
|
bool nextUserFreeUserError() const; ///< Check if next user login should trigger a Free user error.
|
||||||
bool nextUserTFARequired() const; ///< Check if next user login should requires 2FA.
|
bool nextUserTFARequired() const; ///< Check if next user login should requires 2FA.
|
||||||
|
|||||||
@ -150,13 +150,16 @@ bridgepp::SPUser UserTable::userWithID(QString const &userID) {
|
|||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \param[in] username The username.
|
/// \param[in] username The username, or any email address attached to the account.
|
||||||
/// \return The user with the given username.
|
/// \return The user with the given username.
|
||||||
/// \return A null pointer if the user is not in the list.
|
/// \return A null pointer if the user is not in the list.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
bridgepp::SPUser UserTable::userWithUsername(QString const &username) {
|
bridgepp::SPUser UserTable::userWithUsernameOrEmail(QString const &username) {
|
||||||
QList<SPUser>::const_iterator it = std::find_if(users_.constBegin(), users_.constEnd(), [&username](SPUser const &user) -> bool {
|
QList<SPUser>::const_iterator it = std::find_if(users_.constBegin(), users_.constEnd(), [&username](SPUser const &user) -> bool {
|
||||||
return user->username() == username;
|
if (user->username().compare(username, Qt::CaseInsensitive) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return user->addresses().contains(username, Qt::CaseInsensitive);
|
||||||
});
|
});
|
||||||
|
|
||||||
return it == users_.end() ? nullptr : *it;
|
return it == users_.end() ? nullptr : *it;
|
||||||
|
|||||||
@ -40,7 +40,7 @@ public: // member functions.
|
|||||||
void append(bridgepp::SPUser const &user); ///< Append a user.
|
void append(bridgepp::SPUser const &user); ///< Append a user.
|
||||||
bridgepp::SPUser userAtIndex(qint32 index); ///< Return the user at the given index.
|
bridgepp::SPUser userAtIndex(qint32 index); ///< Return the user at the given index.
|
||||||
bridgepp::SPUser userWithID(QString const &userID); ///< Return the user with a given id.
|
bridgepp::SPUser userWithID(QString const &userID); ///< Return the user with a given id.
|
||||||
bridgepp::SPUser userWithUsername(QString const &username); ///< Return the user with a given username.
|
bridgepp::SPUser userWithUsernameOrEmail(QString const &username); ///< Return the user with a given username.
|
||||||
qint32 indexOfUser(QString const &userID); ///< Return the index of a given User.
|
qint32 indexOfUser(QString const &userID); ///< Return the index of a given User.
|
||||||
void touch(qint32 index); ///< touch the user at a given index (indicates it has been modified).
|
void touch(qint32 index); ///< touch the user at a given index (indicates it has been modified).
|
||||||
void touch(QString const& userID); ///< touch the user with the given userID (indicates it has been modified).
|
void touch(QString const& userID); ///< touch the user with the given userID (indicates it has been modified).
|
||||||
|
|||||||
@ -134,6 +134,11 @@ FocusScope {
|
|||||||
stackLayout.currentIndex = 0
|
stackLayout.currentIndex = 0
|
||||||
root.reset()
|
root.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onLoginAlreadyLoggedIn(index) {
|
||||||
|
stackLayout.currentIndex = 0
|
||||||
|
root.reset()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
|
|||||||
Reference in New Issue
Block a user