Got more things functional
This commit is contained in:
parent
a1141cd2b8
commit
fc0c1c7e7a
23 changed files with 1080 additions and 876 deletions
|
@ -1,25 +1,19 @@
|
|||
import 'package:libac_flutter/nbt/NbtUtils.dart';
|
||||
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
||||
import 'package:libac_flutter/nbt/impl/StringTag.dart';
|
||||
|
||||
class Credentials {
|
||||
String username;
|
||||
String password;
|
||||
String secret;
|
||||
bool has_2fa = false;
|
||||
|
||||
Credentials(
|
||||
{required this.username,
|
||||
required this.password,
|
||||
required this.secret,
|
||||
required this.has_2fa});
|
||||
Credentials({
|
||||
required this.username,
|
||||
required this.password,
|
||||
});
|
||||
|
||||
CompoundTag save() {
|
||||
CompoundTag tag = CompoundTag();
|
||||
tag.put(TAG_USERNAME, StringTag.valueOf(username));
|
||||
tag.put(TAG_PASSWORD, StringTag.valueOf(password));
|
||||
tag.put(TAG_SECRET, StringTag.valueOf(secret));
|
||||
NbtUtils.writeBoolean(tag, TAG_2FA, has_2fa);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
@ -27,14 +21,10 @@ class Credentials {
|
|||
static Credentials deserialize(CompoundTag tag) {
|
||||
return Credentials(
|
||||
username: tag.get(TAG_USERNAME)?.asString() ?? "",
|
||||
password: tag.get(TAG_PASSWORD)?.asString() ?? "",
|
||||
secret: tag.get(TAG_SECRET)?.asString() ?? "",
|
||||
has_2fa: NbtUtils.readBoolean(tag, TAG_2FA));
|
||||
password: tag.get(TAG_PASSWORD)?.asString() ?? "");
|
||||
}
|
||||
|
||||
static const TAG_NAME = "credentials";
|
||||
static const TAG_USERNAME = "username";
|
||||
static const TAG_PASSWORD = "password";
|
||||
static const TAG_SECRET = "secret";
|
||||
static const TAG_2FA = "2fa";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue