Add a delay for disabling mods in bulk
This commit is contained in:
parent
b2a7493539
commit
3b7876532b
10 changed files with 57 additions and 39 deletions
|
@ -13,17 +13,20 @@ class User {
|
|||
final String userHash;
|
||||
|
||||
bool login(String username, String passwordHash) {
|
||||
if (userHash != generateValidityCheck())
|
||||
if (userHash != generateValidityCheck()) {
|
||||
return false; // User will be thrown away next time the data is reloaded
|
||||
}
|
||||
|
||||
if (name == username) {
|
||||
if (Hashing.sha256Hash("${passwordSalt}:${passwordHash}") ==
|
||||
if (Hashing.sha256Hash("$passwordSalt:$passwordHash") ==
|
||||
this.passwordHash) {
|
||||
return true;
|
||||
} else
|
||||
} else {
|
||||
return false;
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> sendDiscordActionLog(String actionMessage) async {
|
||||
|
@ -33,7 +36,7 @@ class User {
|
|||
settings.inst!.discord,
|
||||
DiscordHookProps.ALERT,
|
||||
"User Action Alert",
|
||||
"${this}: ${actionMessage}");
|
||||
"$this: $actionMessage");
|
||||
}
|
||||
|
||||
User(
|
||||
|
@ -65,8 +68,8 @@ class User {
|
|||
|
||||
factory User.make(String name, String password, UserLevel level) {
|
||||
String salt = Hashing.sha256Hash(
|
||||
"${Hashing.md5Hash("${Hashing.sha256Hash("${DateTime.now().millisecondsSinceEpoch}")}")}");
|
||||
String hash = Hashing.sha256Hash("${salt}:${Hashing.sha256Hash(password)}");
|
||||
Hashing.md5Hash(Hashing.sha256Hash("${DateTime.now().millisecondsSinceEpoch}")));
|
||||
String hash = Hashing.sha256Hash("$salt:${Hashing.sha256Hash(password)}");
|
||||
String validityCode = generateValidityCode(name, hash, salt, level);
|
||||
|
||||
return User(
|
||||
|
@ -79,13 +82,13 @@ class User {
|
|||
|
||||
String generateValidityCheck() {
|
||||
return Hashing.sha256Hash(
|
||||
"${name}:${passwordHash}:${passwordSalt}:${permissions.ord()}}");
|
||||
"$name:$passwordHash:$passwordSalt:${permissions.ord()}}");
|
||||
}
|
||||
|
||||
static String generateValidityCode(String name, String passwordHash,
|
||||
String passwordSalt, UserLevel permissions) {
|
||||
return Hashing.sha256Hash(
|
||||
"${name}:${passwordHash}:${passwordSalt}:${permissions.ord()}}");
|
||||
"$name:$passwordHash:$passwordSalt:${permissions.ord()}}");
|
||||
}
|
||||
|
||||
static const TAG_NAME = "name";
|
||||
|
@ -96,7 +99,7 @@ class User {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "${permissions.name}: ${name}";
|
||||
return "${permissions.name}: $name";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,11 +85,13 @@ class Settings {
|
|||
FTS = NbtUtils.readBoolean(tag, "fts"); // First Time Setup.
|
||||
// FTS should be disabled by the client when sending it back to the server in a C2SApplySettingsPacket
|
||||
|
||||
if (tag.containsKey("superuser"))
|
||||
if (tag.containsKey("superuser")) {
|
||||
superuser = User.deserialize(tag.get("superuser")!.asCompoundTag());
|
||||
}
|
||||
|
||||
if (tag.containsKey("wine_init"))
|
||||
if (tag.containsKey("wine_init")) {
|
||||
wineInitialized = NbtUtils.readBoolean(tag, "wine_init");
|
||||
}
|
||||
|
||||
if (tag.containsKey("main")) {
|
||||
inst = SettingsEntry.deserialize(tag.get("main")!.asCompoundTag());
|
||||
|
@ -105,11 +107,13 @@ class Settings {
|
|||
|
||||
inst = SettingsEntry.deserialize(tag.get("entry") as CompoundTag);
|
||||
|
||||
if (tag.containsKey("wine_init"))
|
||||
if (tag.containsKey("wine_init")) {
|
||||
wineInitialized = NbtUtils.readBoolean(tag, "wine_init");
|
||||
}
|
||||
|
||||
if (tag.containsKey("superuser"))
|
||||
if (tag.containsKey("superuser")) {
|
||||
superuser = User.deserialize(tag.get("superuser")!.asCompoundTag());
|
||||
}
|
||||
|
||||
FTS = NbtUtils.readBoolean(tag, "fts");
|
||||
} catch (E) {
|
||||
|
|
|
@ -52,7 +52,7 @@ class SettingsEntry {
|
|||
st.admins.add(loadedUser);
|
||||
} else {
|
||||
print(
|
||||
"/!\\ FATAL /!\\\n\n${loadedUser} failed to pass the validity check and has been tampered with");
|
||||
"/!\\ FATAL /!\\\n\n$loadedUser failed to pass the validity check and has been tampered with");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue