예제 #1
0
 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);
     }
 }
예제 #2
0
        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!");
        }
예제 #3
0
 public void commandRegister(Client player, string password)
 {
     if (API.getEntityData(player.handle, "LoggedIn") >= 1)
     {
         API.sendChatMessageToPlayer(player, "You're already logged in.");
     }
     else
     {
         if (password.Length >= 3)
         {
             Mongo.CheckAccountExistsToRegister(player, password);
         }
         else
         {
             API.shared.sendChatMessageToPlayer(player, "Your password must be at least 3 characters long!");
         }
     }
 }