Add a 2fa toggle
This commit is contained in:
parent
fce8632639
commit
54f90c7cdb
3 changed files with 31 additions and 13 deletions
|
@ -4,15 +4,21 @@ part 'credentials.g.dart';
|
||||||
|
|
||||||
@HiveType(typeId: 1)
|
@HiveType(typeId: 1)
|
||||||
class Credentials {
|
class Credentials {
|
||||||
@HiveField(0)
|
@HiveField(0, defaultValue: "")
|
||||||
String username;
|
String username;
|
||||||
|
|
||||||
@HiveField(1)
|
@HiveField(1, defaultValue: "")
|
||||||
String password;
|
String password;
|
||||||
|
|
||||||
@HiveField(2)
|
@HiveField(2, defaultValue: "")
|
||||||
String secret;
|
String secret;
|
||||||
|
|
||||||
|
@HiveField(3, defaultValue: false)
|
||||||
|
bool has_2fa = false;
|
||||||
|
|
||||||
Credentials(
|
Credentials(
|
||||||
{required this.username, required this.password, required this.secret});
|
{required this.username,
|
||||||
|
required this.password,
|
||||||
|
required this.secret,
|
||||||
|
required this.has_2fa});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,12 @@ Future<void> doDownloadMods(String modsFolder) async {
|
||||||
Settings settings = Settings();
|
Settings settings = Settings();
|
||||||
|
|
||||||
// Now, invoke SteamCmd to download the workshop mods. This is an authenticated action, and does require Scmd2fa
|
// Now, invoke SteamCmd to download the workshop mods. This is an authenticated action, and does require Scmd2fa
|
||||||
var result = await Process.run(settings.getSteamCmd2FA(),
|
String code = "";
|
||||||
["--raw", "--secret", settings.inst!.steam_creds!.secret]);
|
if (settings.inst!.steam_creds!.has_2fa) {
|
||||||
var code = result.stdout as String;
|
var result = await Process.run(settings.getSteamCmd2FA(),
|
||||||
|
["--raw", "--secret", settings.inst!.steam_creds!.secret]);
|
||||||
|
code = result.stdout as String;
|
||||||
|
}
|
||||||
|
|
||||||
// Build download command
|
// Build download command
|
||||||
List<String> manifest = [
|
List<String> manifest = [
|
||||||
|
@ -26,7 +29,7 @@ Future<void> doDownloadMods(String modsFolder) async {
|
||||||
"+login",
|
"+login",
|
||||||
settings.inst!.steam_creds!.username,
|
settings.inst!.steam_creds!.username,
|
||||||
settings.inst!.steam_creds!.password,
|
settings.inst!.steam_creds!.password,
|
||||||
code.trim()
|
if (settings.inst!.steam_creds!.has_2fa) code.trim()
|
||||||
];
|
];
|
||||||
for (Mod M in settings.inst!.mods) {
|
for (Mod M in settings.inst!.mods) {
|
||||||
manifest.add("+workshop_download_item");
|
manifest.add("+workshop_download_item");
|
||||||
|
@ -41,7 +44,7 @@ Future<void> doDownloadMods(String modsFolder) async {
|
||||||
//print(
|
//print(
|
||||||
// "Running command: ${settings.getSteamCmd()} ${manifest.join(" ")}");
|
// "Running command: ${settings.getSteamCmd()} ${manifest.join(" ")}");
|
||||||
|
|
||||||
result = await Process.run(settings.getSteamCmd(), manifest);
|
var result = await Process.run(settings.getSteamCmd(), manifest);
|
||||||
|
|
||||||
print(result.stdout);
|
print(result.stdout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,8 @@ class SteamCMDState extends State<SteamCMD> {
|
||||||
|
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
// Download zip file
|
// Download zip file
|
||||||
final path = "${settings.steamcmd_path}${Platform.pathSeparator}windows.zip";
|
final path =
|
||||||
|
"${settings.steamcmd_path}${Platform.pathSeparator}windows.zip";
|
||||||
final reply = await dio.download(windows, path);
|
final reply = await dio.download(windows, path);
|
||||||
|
|
||||||
final bytes = File(path).readAsBytesSync();
|
final bytes = File(path).readAsBytesSync();
|
||||||
|
@ -91,7 +92,8 @@ class SteamCMDState extends State<SteamCMD> {
|
||||||
await Process.start("steamcmd.exe", ["+quit"]);
|
await Process.start("steamcmd.exe", ["+quit"]);
|
||||||
} else {
|
} else {
|
||||||
// Download tgz file
|
// Download tgz file
|
||||||
final path = "${settings.steamcmd_path}${Platform.pathSeparator}linux.tgz";
|
final path =
|
||||||
|
"${settings.steamcmd_path}${Platform.pathSeparator}linux.tgz";
|
||||||
final reply = await dio.download(linux, path);
|
final reply = await dio.download(linux, path);
|
||||||
|
|
||||||
final bytes = File(path).readAsBytesSync();
|
final bytes = File(path).readAsBytesSync();
|
||||||
|
@ -175,6 +177,7 @@ class CredentialsPrompt extends StatelessWidget {
|
||||||
TextEditingController password = TextEditingController();
|
TextEditingController password = TextEditingController();
|
||||||
TextEditingController secret = TextEditingController();
|
TextEditingController secret = TextEditingController();
|
||||||
bool initialInitDone = false;
|
bool initialInitDone = false;
|
||||||
|
bool z2fa = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -268,7 +271,12 @@ class CredentialsPrompt extends StatelessWidget {
|
||||||
"2FA Shared Secret Code (Do Not Share With Others!)"),
|
"2FA Shared Secret Code (Do Not Share With Others!)"),
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
)
|
),
|
||||||
|
SwitchListTile(
|
||||||
|
value: z2fa,
|
||||||
|
onChanged: (value) {
|
||||||
|
z2fa = value;
|
||||||
|
})
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
|
@ -277,7 +285,8 @@ class CredentialsPrompt extends StatelessWidget {
|
||||||
Credentials(
|
Credentials(
|
||||||
username: username.text,
|
username: username.text,
|
||||||
password: password.text,
|
password: password.text,
|
||||||
secret: secret.text));
|
secret: secret.text,
|
||||||
|
has_2fa: z2fa));
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue