mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-26 05:04:20 +00:00
Grant superuser permissions to accounts created before the permissions update
This commit is contained in:
parent
4cf734fb61
commit
efc9a4b3e5
@ -4,6 +4,7 @@ import dev.morphia.annotations.Collation;
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import dev.morphia.annotations.PreLoad;
|
||||
import emu.grasscutter.database.DatabaseHelper;
|
||||
import emu.grasscutter.utils.Crypto;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
@ -12,6 +13,8 @@ import dev.morphia.annotations.IndexOptions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
|
||||
@Entity(value = "accounts", noClassnameStored = true)
|
||||
public class Account {
|
||||
@Id private String id;
|
||||
@ -114,6 +117,14 @@ public class Account {
|
||||
return this.token;
|
||||
}
|
||||
|
||||
@PreLoad
|
||||
public void onLoad(DBObject dbObj) {
|
||||
// Grant the superuser permissions to accounts created before the permissions update
|
||||
if (!dbObj.containsField("permissions")) {
|
||||
this.addPermission("*");
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
DatabaseHelper.saveAccount(this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user