MCPcopy Create free account
hub / github.com/MultiMC/Launcher / login

Method login

launcher/LaunchController.cpp:98–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96
97
98void LaunchController::login() {
99 decideAccount();
100
101 // if no account is selected, we bail
102 if (!m_accountToUse)
103 {
104 emitFailed(tr("No account selected for launch."));
105 return;
106 }
107
108 // we try empty password first :)
109 QString password;
110 // we loop until the user succeeds in logging in or gives up
111 bool tryagain = true;
112 // the failure. the default failure.
113 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.");
114 QString failReason = needLoginAgain;
115
116 while (tryagain)
117 {
118 m_session = std::make_shared<AuthSession>();
119 m_session->wants_online = m_online;
120 m_accountToUse->fillSession(m_session);
121
122 switch(m_accountToUse->accountState()) {
123 case AccountState::Offline: {
124 m_session->wants_online = false;
125 // NOTE: fallthrough is intentional
126 }
127 case AccountState::Online: {
128 if(!m_session->wants_online) {
129 QString usedname;
130 if(m_offlineName.isEmpty()) {
131 // we ask the user for a player name
132 bool ok = false;
133 QString lastOfflinePlayerName = APPLICATION->settings()->get("LastOfflinePlayerName").toString();
134 usedname = lastOfflinePlayerName.isEmpty() ? m_session->player_name : lastOfflinePlayerName;
135 QString name = QInputDialog::getText(
136 m_parentWidget,
137 tr("Player name"),
138 tr("Choose your offline mode player name."),
139 QLineEdit::Normal,
140 usedname,
141 &ok
142 );
143 if (!ok)
144 {
145 tryagain = false;
146 break;
147 }
148 if (name.length())
149 {
150 usedname = name;
151 APPLICATION->settings()->set("LastOfflinePlayerName", usedname);
152 }
153 }
154 else {
155 usedname = m_offlineName;

Callers

nothing calls this directly

Calls 15

fillSessionMethod · 0.80
accountStateMethod · 0.80
isEmptyMethod · 0.80
lengthMethod · 0.80
MakeOfflineMethod · 0.80
ownsMinecraftMethod · 0.80
hasProfileMethod · 0.80
MakeDemoMethod · 0.80
setSkipButtonMethod · 0.80
currentTaskMethod · 0.80
execWithTaskMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected