Skip to content

Commit

Permalink
Merge pull request #52 from Sadzurami/feat/import-secrets-wo-deviceid
Browse files Browse the repository at this point in the history
Add support for secrets without deviceid
  • Loading branch information
yakikotori authored Jan 30, 2024
2 parents 89f05ca + f9a87c8 commit f008145
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions BotLooter/Resources/SteamAccountCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private static async Task<int> LoadFromSteamSessions(List<SteamAccountCredential
return loadedCount;
}

private static string GetDeviceId(string steamId)
public static string GetDeviceId(string steamId)
{
var bytes = Encoding.UTF8.GetBytes(steamId);
var hashBytes = SHA1.HashData(bytes);
Expand Down Expand Up @@ -218,9 +218,9 @@ private static async Task<List<SteamGuardAccount>> GetSecretFiles(string directo
continue;
}

if (secret is not { SharedSecret: not null, IdentitySecret: not null, DeviceID: not null })
if (secret is not { SharedSecret: not null, IdentitySecret: not null })
{
Log.Logger.Warning("В секретном файле отсутствует shared_secret, identity_secret или device_id: {Path}", filePath);
Log.Logger.Warning("В секретном файле отсутствует shared_secret или identity_secret: {Path}", filePath);
continue;
}

Expand Down
6 changes: 6 additions & 0 deletions BotLooter/Steam/SteamUserSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using RestSharp;
using SteamAuth;
using SteamSession;
using static BotLooter.Resources.SteamAccountCredentials;

namespace BotLooter.Steam;

Expand Down Expand Up @@ -105,6 +106,11 @@ private async ValueTask<bool> IsSessionAlive()
SteamLoginSecure = steamLoginSecure,
SteamID = SteamId.Value
};

if (Credentials.SteamGuardAccount.DeviceID is null)
{
Credentials.SteamGuardAccount.DeviceID = GetDeviceId(SteamId.Value.ToString());
}

return (true, "Авторизовался");
}
Expand Down

0 comments on commit f008145

Please sign in to comment.