Skip to content

Commit

Permalink
Update MicrosoftAuthenticator.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Jan 24, 2025
1 parent 1d25b21 commit b0f6494
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public async Task<AuthResultBase> AuthTaskAsync(bool userField = false)

var cacheTokenResult = await this.CacheTokenProvider(this);

if (cacheTokenResult is { IsAuthResultValid: true, AuthResult: { Error: null, AuthStatus: AuthStatus.Succeeded } })
if (cacheTokenResult is { IsAuthResultValid: true, AuthResult: MicrosoftAuthResult { Error: null, AuthStatus: AuthStatus.Succeeded, ExpiresIn: >= 60 } })
return cacheTokenResult.AuthResult;

if (!cacheTokenResult.IsCredentialValid || cacheTokenResult.CacheAuthResult == null)
Expand All @@ -112,7 +112,6 @@ public async Task<AuthResultBase> AuthTaskAsync(bool userField = false)
var accessToken = cacheTokenResult.CacheAuthResult.AccessToken;
var refreshToken = cacheTokenResult.CacheAuthResult.RefreshToken;
var idToken = cacheTokenResult.CacheAuthResult.IdToken;
var expiresIn = cacheTokenResult.CacheAuthResult.ExpiresIn;

#region STAGE 1

Expand Down Expand Up @@ -290,7 +289,7 @@ await profileResRes.Content.ReadFromJsonAsync(MojangErrorResponseModelContext.De
var accountModel = new AccountModel
{
AccessToken = mcRes.AccessToken,
AccessTokenExpiresAt = DateTime.Now.AddSeconds(expiresIn > 0 ? expiresIn : mcRes.ExpiresIn),
AccessTokenExpiresAt = DateTime.Now.AddSeconds(mcRes.ExpiresIn),
Avatar = profileRes.GetActiveSkin()?.Url,
Cape = profileRes.GetActiveCape()?.Url,
EligibleForMigration = false,
Expand Down Expand Up @@ -388,6 +387,7 @@ await profileResRes.Content.ReadFromJsonAsync(MojangErrorResponseModelContext.De
return new MicrosoftAuthResult
{
AccessToken = value.AccessToken,
ExpiresIn = (long)(value.AccessTokenExpiresAt - DateTime.Now).TotalSeconds,
AuthStatus = AuthStatus.Succeeded,
Skin = value.Avatar,
Cape = value.Cape,
Expand Down

0 comments on commit b0f6494

Please sign in to comment.