fix(GODT-2778): fix login screen being disabled after an 'already logged in' error.
This commit is contained in:
parent
8248491833
commit
6cb52cacc9
|
@ -385,6 +385,14 @@ Status GRPCService::Login(ServerContext *, LoginRequest const *request, Empty *)
|
|||
app().log().debug(__FUNCTION__);
|
||||
UsersTab &usersTab = app().mainWindow().usersTab();
|
||||
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()) {
|
||||
qtProxy_.sendDelayedEvent(newLoginError(LoginErrorType::USERNAME_PASSWORD_ERROR, usersTab.usernamePasswordErrorMessage()));
|
||||
return Status::OK;
|
||||
|
@ -826,7 +834,7 @@ bool GRPCService::sendEvent(SPStreamEvent const &event) {
|
|||
//****************************************************************************************************************************************************
|
||||
void GRPCService::finishLogin() {
|
||||
UsersTab &usersTab = app().mainWindow().usersTab();
|
||||
SPUser user = usersTab.userWithUsername(loginUsername_);
|
||||
SPUser user = usersTab.userWithUsernameOrEmail(loginUsername_);
|
||||
bool const alreadyExist = user.get();
|
||||
if (!user) {
|
||||
user = randomUser();
|
||||
|
|
|
@ -272,8 +272,8 @@ bridgepp::SPUser UsersTab::userWithID(QString const &userID) {
|
|||
/// \return The user with the given username.
|
||||
/// \return A null pointer if the user is not in the list.
|
||||
//****************************************************************************************************************************************************
|
||||
bridgepp::SPUser UsersTab::userWithUsername(QString const &username) {
|
||||
return users_.userWithUsername(username);
|
||||
bridgepp::SPUser UsersTab::userWithUsernameOrEmail(QString const &username) {
|
||||
return users_.userWithUsernameOrEmail(username);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public: // member functions.
|
|||
UsersTab &operator=(UsersTab &&) = delete; ///< Disabled move assignment operator.
|
||||
UserTable &userTable(); ///< Returns a reference to the user table.
|
||||
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 nextUserFreeUserError() const; ///< Check if next user login should trigger a Free user error.
|
||||
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 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 {
|
||||
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;
|
||||
|
|
|
@ -40,7 +40,7 @@ public: // member functions.
|
|||
void append(bridgepp::SPUser const &user); ///< Append a user.
|
||||
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 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.
|
||||
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).
|
||||
|
|
|
@ -134,6 +134,11 @@ FocusScope {
|
|||
stackLayout.currentIndex = 0
|
||||
root.reset()
|
||||
}
|
||||
|
||||
function onLoginAlreadyLoggedIn(index) {
|
||||
stackLayout.currentIndex = 0
|
||||
root.reset()
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
|
|
Loading…
Reference in New Issue