MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / shouldRefresh

Method shouldRefresh

launcher/minecraft/auth/MinecraftAccount.cpp:201–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201bool MinecraftAccount::shouldRefresh() const
202{
203 /*
204 * Never refresh accounts that are being used by the game, it breaks the game session.
205 * Always refresh accounts that have not been refreshed yet during this session.
206 * Don't refresh broken accounts.
207 * Refresh accounts that would expire in the next 12 hours (fresh token validity is 24 hours).
208 */
209 if (isInUse()) {
210 return false;
211 }
212 switch (data.validity_) {
213 case Validity::Certain: {
214 break;
215 }
216 case Validity::None: {
217 return false;
218 }
219 case Validity::Assumed: {
220 return true;
221 }
222 }
223 auto now = QDateTime::currentDateTimeUtc();
224 auto issuedTimestamp = data.yggdrasilToken.issueInstant;
225 auto expiresTimestamp = data.yggdrasilToken.notAfter;
226
227 if (!expiresTimestamp.isValid()) {
228 expiresTimestamp = issuedTimestamp.addSecs(24 * 3600);
229 }
230 if (now.secsTo(expiresTimestamp) < (12 * 3600)) {
231 return true;
232 }
233 return false;
234}
235
236void MinecraftAccount::fillSession(AuthSessionPtr session)
237{

Callers 2

loginMethod · 0.80
fillQueueMethod · 0.80

Calls 1

isValidMethod · 0.45

Tested by

no test coverage detected