Start to update stuff
This commit is contained in:
parent
110b2d150c
commit
399d884681
18 changed files with 217 additions and 240 deletions
|
@ -1,19 +1,11 @@
|
|||
import 'package:hive/hive.dart';
|
||||
import 'package:libac_flutter/nbt/NbtUtils.dart';
|
||||
import 'package:libac_flutter/nbt/impl/CompoundTag.dart';
|
||||
import 'package:libac_flutter/nbt/impl/StringTag.dart';
|
||||
|
||||
part 'credentials.g.dart';
|
||||
|
||||
@HiveType(typeId: 1)
|
||||
class Credentials {
|
||||
@HiveField(0, defaultValue: "")
|
||||
String username;
|
||||
|
||||
@HiveField(1, defaultValue: "")
|
||||
String password;
|
||||
|
||||
@HiveField(2, defaultValue: "")
|
||||
String secret;
|
||||
|
||||
@HiveField(3, defaultValue: false)
|
||||
bool has_2fa = false;
|
||||
|
||||
Credentials(
|
||||
|
@ -21,4 +13,28 @@ class Credentials {
|
|||
required this.password,
|
||||
required this.secret,
|
||||
required this.has_2fa});
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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