public static function validatePassword(User $user, $value)
 {
     $length = strlen($value);
     $config = $user->getMain()->getConfig();
     $messages = $user->getMain()->getMessages();
     $minLength = $config->getNested("Registration.MinLength", 4);
     if ($length < $minLength) {
         $user->getPlayer()->sendMessage($messages->getNested("Register.PasswordUnderflow", "too short"));
         return false;
     }
     $maxLength = $config->getNested("Registration.MaxLength", -1);
     if ($maxLength !== -1 and $length > $maxLength) {
         $user->getPlayer()->sendMessage($messages->getNested("Register.PasswordOverflow", "too long"));
         return false;
     }
     if ($config->getNested("Registration.BanPureLetters", false) and preg_match('/^[a-z]+$/i', $value)) {
         $user->getPlayer()->sendMessage($messages->getNested("Register.PasswordPureLetters", "only letters"));
         return false;
     }
     if ($config->getNested("Registration.BanPureNumbers", false) and preg_match('/^[0-9]+$/', $value)) {
         $user->getPlayer()->sendMessage($messages->getNested("Register.PasswordPureNumbers", "only numbers"));
         return false;
     }
     if ($config->getNested("Registration.DisallowSlashes", true) and $value[0] === "/") {
         $user->getPlayer()->sendMessage($messages->getNested("Register.PasswordSlashes", "do not start with slashes"));
         return false;
     }
     return true;
 }
Beispiel #2
0
 public function __construct(User $user)
 {
     $this->user = $user;
     $this->steps[] = new PasswordInputRegistrationStep($user);
     if ($this->user->getMain()->getConfig()->getNested("Registration.RequireConfirm", true)) {
         $this->steps[] = new PasswordConfirmRegistrationStep($user);
     }
     foreach ($user->getMain()->getConfig()->getNested("Registration.ExtraFields", []) as $i => $field) {
         if (!isset($field["Message"], $field["FieldName"])) {
             $this->user->getMain()->getLogger()->warning("The #" . ($i + 1) . " entry in Registration.ExtraFields is does not have the Message/FieldName line! It is not going to be added.");
             continue;
         }
         $message = $field["Message"];
         $fieldName = $field["FieldName"];
         $regex = null;
         $error = null;
         if (isset($field["RegExp"], $field["ErrorMessage"])) {
             $regex = $field["RegExp"];
             $error = $field["ErrorMessage"];
         }
         $this->addStep(new ConfigDefinedRegistrationStep($this->user, $message, $fieldName, $regex, $error));
     }
 }
 protected function onRun(array $args, User $user)
 {
     if (!isset($args[0])) {
         return "Usage: " . $this->getUsage();
     }
     $password = $args[0];
     $hash = HereAuth::hash($password, $user->getPlayer());
     $firstHash = $user->getChangepwHash();
     if ($firstHash !== null) {
         $user->setChangepwHash(null);
         if ($firstHash === $hash) {
             $user->getAccountInfo()->passwordHash = $hash;
             return $this->getMessage("Commands.ChangePassword.Success", "Your password has been changed.");
         }
         return $this->getMessage("Commands.ChangePassword.DoubleCheckFailure", "Your password is different this time! Aborted.");
     }
     if (!PasswordInputRegistrationStep::validatePassword($user, $password)) {
         return false;
     }
     $user->setChangepwHash($hash);
     return $this->getMessage("Commands.ChangePassword.RequestRepeat", "Please run this command again to confirm.");
 }
Beispiel #4
0
 private function getHelpMessage(User $user)
 {
     $opts = $user->getAccountInfo()->opts;
     $output = "Your HereAuth options:\n";
     $mlp = $opts->maskLocPos;
     if (!preg_match('#^((\\?spawn\\?)|((\\-)?[0-9]+,(\\-)?[0-9]+,(\\-)?[0-9]+))@([^/\\\\]+)$#', $mlp, $match)) {
         $maskLocString = "none";
     } else {
         $pos = $match[1];
         $world = $match[7];
         if ($pos === "?spawn?") {
             $maskLocString = "spawn";
         } else {
             $maskLocString = "({$pos})";
         }
         $maskLocString .= " in ";
         if ($world === "?default?") {
             $maskLocString .= " default world";
         } elseif ($world === "?current?") {
             $maskLocString .= " current world";
         } else {
             $maskLocString .= " world \"{$world}\"";
         }
     }
     $optMap = ["AutoAuth through client secret" => $opts->autoSecret, "AutoAuth through UUID" => $opts->autoUuid, "AutoAuth through IP address" => $opts->autoIp, "Location masking" => $opts->maskLoc, "Location masking position" => $maskLocString, "Inventory masking" => $opts->maskInv, "Multi-factor auth (MFA) through skin" => $opts->multiSkin, "MFA through IP address" => $opts->multiIp, "MFA timeout" => $opts->multiTimeout === -1 ? "forever" : $opts->multiTimeout . " day(s)"];
     foreach ($optMap as $key => $value) {
         $output .= TextFormat::GOLD . $key . ": ";
         $output .= TextFormat::RED . $this->stringify($value) . "\n";
     }
     $output .= TextFormat::AQUA . "====================\n";
     $output .= TextFormat::LIGHT_PURPLE . "To change these values:\n";
     $output .= "/opt as on|off ";
     $output .= TextFormat::GREEN . "Toggle AutoAuth through " . TextFormat::YELLOW . "client secret\n";
     $output .= "/opt au on|off ";
     $output .= TextFormat::GREEN . "Toggle AutoAuth through " . TextFormat::YELLOW . "UUID\n";
     $output .= "/opt ai on|off ";
     $output .= TextFormat::GREEN . "Toggle AutoAuth through " . TextFormat::YELLOW . "IP\n";
     $output .= "/opt ml on|off ";
     $output .= TextFormat::GREEN . "Toggle " . TextFormat::YELLOW . "location " . TextFormat::GREEN . "masking\n";
     $output .= "/opt mlt here|<x,y,z@world> ";
     $output .= TextFormat::GREEN . "Set " . TextFormat::YELLOW . "location " . TextFormat::GREEN . "masking";
     $output .= "\n";
     $output .= "/opt mi on|off ";
     $output .= TextFormat::GREEN . "Toggle " . TextFormat::YELLOW . "inventory " . TextFormat::GREEN . "masking\n";
     $output .= "/opt mfas on|off ";
     $output .= TextFormat::GREEN . "Toggle " . TextFormat::YELLOW . "skin MFA (multi-factor authentication)\n";
     $output .= "/opt mfai on|off ";
     $output .= TextFormat::GREEN . "Toggle " . TextFormat::YELLOW . "IP MFA\n";
     $output .= "/opt mfat <timeout|forever> ";
     $output .= TextFormat::GREEN . "Set " . TextFormat::YELLOW . "MFA timeout in days " . TextFormat::GREEN . "(or \"forever\")\n";
     //		$output .= "If /opt doesn't work, try /auth instead"; // <-- how would people even be able to execute this command if it doesn't work?
     return $output;
 }
Beispiel #5
0
 protected function onRun(array $args, User $user)
 {
     return $user->lock();
 }
Beispiel #6
0
 protected function onRun(array $args, User $user)
 {
     return $user->logout($this->getMessage("Commands.Logout.Success", "You have logged out of your account"));
 }
Beispiel #7
0
 protected function onRun(array $args, User $user)
 {
     $user->startRegistration();
     return true;
 }
Beispiel #8
0
 private function getHelpMessage(User $user)
 {
     $opts = $user->getAccountInfo()->opts;
     $output = "Your HereAuth options:\n";
     $mlp = $opts->maskLocPos;
     if (!preg_match('#^((\\?spawn\\?)|((\\-)?[0-9]+,(\\-)?[0-9]+,(\\-)?[0-9]+))@([^/\\\\]+)$#', $mlp, $match)) {
         $maskLocString = "none";
     } else {
         $pos = $match[1];
         $world = $match[7];
         if ($pos === "?spawn?") {
             $maskLocString = "spawn";
         } else {
             $maskLocString = "({$pos})";
         }
         $maskLocString .= " in ";
         if ($world === "?default?") {
             $maskLocString .= " default world";
         } elseif ($world === "?current?") {
             $maskLocString .= " current world";
         } else {
             $maskLocString .= " world \"{$world}\"";
         }
     }
     $opts = ["AutoAuth through client secret" => $opts->autoSecret, "AutoAuth through UUID" => $opts->autoUuid, "AutoAuth through IP address" => $opts->autoIp, "Location masking" => $opts->maskLoc, "Location masking position" => $maskLocString, "Inventory masking" => $opts->maskInv, "Multi-factor auth (MFA) through skin" => $opts->multiSkin, "MFA through IP address" => $opts->multiIp];
     foreach ($opts as $key => $value) {
         $output .= TextFormat::GOLD . $key . ": ";
         $output .= TextFormat::RED . $this->stringify($value) . "\n";
     }
     $output .= TextFormat::AQUA . "====================\n";
     $output .= TextFormat::LIGHT_PURPLE . "To change these values:\n";
     $output .= "/auth as on|off ";
     $output .= TextFormat::GREEN . "Toggle AutoAuth through " . TextFormat::YELLOW . "client secret\n";
     $output .= "/auth au on|off ";
     $output .= TextFormat::GREEN . "Toggle AutoAuth through " . TextFormat::YELLOW . "UUID\n";
     $output .= "/auth ai on|off ";
     $output .= TextFormat::GREEN . "Toggle AutoAuth through " . TextFormat::YELLOW . "IP\n";
     $output .= "/auth ml on|off ";
     $output .= TextFormat::GREEN . "Toggle " . TextFormat::YELLOW . "location masking\n";
     $output .= "/auth mlt here|<x,y,z@world> ";
     $output .= TextFormat::GREEN . "Set " . TextFormat::YELLOW . "location masking\n";
     $output .= "/auth mi on|off ";
     $output .= TextFormat::GREEN . "Toggle " . TextFormat::YELLOW . "inventory masking\n";
     $output .= "/auth mafs on|off";
     $output .= TextFormat::GREEN . "Toggle " . TextFormat::YELLOW . "skin MAF (multi-factor authentication)\n";
     $output .= "/auth mafi on|off";
     $output .= TextFormat::GREEN . "Toggle " . TextFormat::YELLOW . "IP MAF (multi-factor authentication)\n";
     return $output;
 }
 public function __construct(User $user)
 {
     parent::__construct($user->getMain());
     $this->user = $user;
 }