| 92 | |
| 93 | |
| 94 | void LaunchController::login() { |
| 95 | decideAccount(); |
| 96 | |
| 97 | // if no account is selected, we bail |
| 98 | if (!m_accountToUse) |
| 99 | { |
| 100 | emitFailed(tr("No account selected for launch.")); |
| 101 | return; |
| 102 | } |
| 103 | |
| 104 | // we try empty password first :) |
| 105 | QString password; |
| 106 | // we loop until the user succeeds in logging in or gives up |
| 107 | bool tryagain = true; |
| 108 | // the failure. the default failure. |
| 109 | const QString needLoginAgain = tr("Your account is currently not logged in. Please enter your password to log in again. <br /> <br /> This could be caused by a password change."); |
| 110 | QString failReason = needLoginAgain; |
| 111 | |
| 112 | while (tryagain) |
| 113 | { |
| 114 | m_session = std::make_shared<AuthSession>(); |
| 115 | m_session->wants_online = m_online; |
| 116 | m_accountToUse->fillSession(m_session); |
| 117 | |
| 118 | switch(m_accountToUse->accountState()) { |
| 119 | case AccountState::Offline: { |
| 120 | m_session->wants_online = false; |
| 121 | // NOTE: fallthrough is intentional |
| 122 | } |
| 123 | case AccountState::Online: { |
| 124 | if(!m_session->wants_online) { |
| 125 | // we ask the user for a player name |
| 126 | bool ok = false; |
| 127 | QString usedname = m_session->player_name; |
| 128 | QString name = QInputDialog::getText( |
| 129 | m_parentWidget, |
| 130 | tr("Player name"), |
| 131 | tr("Choose your offline mode player name."), |
| 132 | QLineEdit::Normal, |
| 133 | m_session->player_name, |
| 134 | &ok |
| 135 | ); |
| 136 | if (!ok) |
| 137 | { |
| 138 | tryagain = false; |
| 139 | break; |
| 140 | } |
| 141 | if (name.length()) |
| 142 | { |
| 143 | usedname = name; |
| 144 | } |
| 145 | m_session->MakeOffline(usedname); |
| 146 | // offline flavored game from here :3 |
| 147 | } |
| 148 | if(m_accountToUse->ownsMinecraft() && !m_accountToUse->hasProfile()) { |
| 149 | auto entitlement = m_accountToUse->accountData()->minecraftEntitlement; |
| 150 | QString errorString; |
| 151 | if(!entitlement.canPlayMinecraft) { |
nothing calls this directly
no test coverage detected