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 #2
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 #3
0
 protected function hasPerm(User $user)
 {
     return $user->isPlaying() and $user->getAccountInfo()->passwordHash;
 }
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}\"";
         }
     }
     $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;
 }