public void commandLogin(Client player, string password) { if (API.getEntityData(player.handle, "LoggedIn") >= 1) { API.sendChatMessageToPlayer(player, "You're already logged in."); } else { string hashedPassword = Mongo.GetStringSha256Hash(password); Mongo.CheckAccountExistsToLogin(player, hashedPassword); } }
public static async void RegisterAccountAsync(Client player, string password) { API.shared.sendChatMessageToPlayer(player, "Hold on, we're registering your account now..."); string hashedPassword = Mongo.GetStringSha256Hash(password); var document = new BsonDocument { { "Name", player.name }, { "Password", hashedPassword } }; var collection = DatabaseClass.CnRDatabase.GetCollection <BsonDocument>("accounts"); await collection.InsertOneAsync(document); API.shared.sendChatMessageToPlayer(player, "Account registered! You can now log in!"); }