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

Method shouldRefresh

launcher/minecraft/auth/MinecraftAccount.cpp:187–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187bool MinecraftAccount::shouldRefresh() const {
188 /*
189 * Never refresh accounts that are being used by the game, it breaks the game session.
190 * Always refresh accounts that have not been refreshed yet during this session.
191 * Don't refresh broken accounts.
192 * Refresh accounts that would expire in the next 12 hours (fresh token validity is 24 hours).
193 */
194 if(isInUse()) {
195 return false;
196 }
197 switch(data.validity_) {
198 case Katabasis::Validity::Certain: {
199 break;
200 }
201 case Katabasis::Validity::None: {
202 return false;
203 }
204 case Katabasis::Validity::Assumed: {
205 return true;
206 }
207 }
208 auto now = QDateTime::currentDateTimeUtc();
209 auto issuedTimestamp = data.yggdrasilToken.issueInstant;
210 auto expiresTimestamp = data.yggdrasilToken.notAfter;
211
212 if(!expiresTimestamp.isValid()) {
213 expiresTimestamp = issuedTimestamp.addSecs(24 * 3600);
214 }
215 if (now.secsTo(expiresTimestamp) < (12 * 3600)) {
216 return true;
217 }
218 return false;
219}
220
221void MinecraftAccount::fillSession(AuthSessionPtr session)
222{

Callers 1

fillQueueMethod · 0.80

Calls 1

isValidMethod · 0.45

Tested by

no test coverage detected