Example #1
0
 public function requireLogin()
 {
     global $whmcs;
     if ($this->isLoggedIn()) {
         if (WHMCS_Session::get("2fabackupcodenew")) {
             $this->setTemplate("logintwofa");
             $twofa = new WHMCS_2FA();
             if ($twofa->setClientID($this->getUserID())) {
                 $backupcode = $twofa->generateNewBackupCode();
                 $this->assign("newbackupcode", $backupcode);
                 WHMCS_Session::delete("2fabackupcodenew");
             } else {
                 $this->assign("newbackupcodeerror", true);
             }
             $this->output();
             exit;
         }
         return true;
     }
     $_SESSION['loginurlredirect'] = html_entity_decode($_SERVER['REQUEST_URI']);
     if (WHMCS_Session::get("2faverifyc")) {
         $this->setTemplate("logintwofa");
         if (WHMCS_Session::get("2fabackupcodenew")) {
             $this->assign("newbackupcode", true);
         } else {
             if ($whmcs->get_req_var("incorrect")) {
                 $this->assign("incorrect", true);
             }
         }
         $twofa = new WHMCS_2FA();
         if ($twofa->setClientID(WHMCS_Session::get("2faclientid"))) {
             if (!$twofa->isActiveClients() || !$twofa->isEnabled()) {
                 WHMCS_Session::destroy();
                 redir();
             }
             if ($whmcs->get_req_var("backupcode")) {
                 $this->assign("backupcode", true);
             } else {
                 $challenge = $twofa->moduleCall("challenge");
                 if ($challenge) {
                     $this->assign("challenge", $challenge);
                 } else {
                     $this->assign("error", "Bad 2 Factor Auth Module. Please contact support.");
                 }
             }
         } else {
             $this->assign("error", "An error occurred. Please try again.");
         }
     } else {
         $this->setTemplate("login");
         $this->assign("loginpage", true);
         $this->assign("formaction", "dologin.php");
         if ($whmcs->get_req_var("incorrect")) {
             $this->assign("incorrect", true);
         }
     }
     $this->output();
     exit;
 }
Example #2
0
 public function handleInvalidToken()
 {
     if (defined("CLIENTAREA")) {
         WHMCS_Session::destroy();
         redir("", "clientarea.php");
     }
     exit("Invalid Token");
 }
Example #3
0
 }
 echo "<div id=\"login_msg\"><span style=\"font-size:14px;\"><strong>" . $msgtitle . "</strong></span><br>" . $msg . "</div>";
 if (isset($_SESSION['2fabackupcodenew'])) {
     $twofa = new WHMCS_2FA();
     if ($twofa->setAdminID($_SESSION['2faadminid'])) {
         $backupcode = $twofa->generateNewBackupCode();
         echo "<div id=\"login\"><p align=\"center\">Your New Backup Code is:</p><div style=\"margin:20px auto;padding:10px;width:280px;background-color:#F2D4CE;border:1px dashed #AE432E;text-align:center;font-size:20px;\">" . $backupcode . "</div><p align=\"center\">Write this down on paper and keep it safe.<br />It will be needed if you ever lose your 2nd factor device or it is unavailable to you again in future.</p><form method=\"post\" action=\"dologin.php\"><p align=\"center\"><input type=\"submit\" value=\"Continue to Admin Area &raquo;\" /></p></form></div>";
     } else {
         echo "<div id=\"login\">An error occurred. Please try again.</div>";
     }
 } else {
     if (isset($_SESSION['2faverify'])) {
         $twofa = new WHMCS_2FA();
         if ($twofa->setAdminID($_SESSION['2faadminid'])) {
             if (!$twofa->isActiveAdmins() || !$twofa->isEnabled()) {
                 WHMCS_Session::destroy();
                 redir();
             }
             if ($whmcs->get_req_var("backupcode")) {
                 echo "<div id=\"login\"><form method=\"post\" action=\"dologin.php\"><input type=\"hidden\" name=\"backupcode\" value=\"1\" /><p align=\"center\"><input type=\"text\" name=\"code\" size=\"25\" /> <input type=\"submit\" value=\"Login &raquo;\" /></p><p align=\"center\">Enter Your Backup Code Above to Login</p></form></div>";
             } else {
                 $challenge = $twofa->moduleCall("challenge");
                 if ($challenge) {
                     echo "<div id=\"login\">" . $challenge . "<p align=\"center\">Can't Access Your 2nd Factor Device? <a href=\"login.php?backupcode=1\">Login using Backup Code</a></p></div>";
                 } else {
                     echo "<div id=\"login\">Bad 2 Factor Auth Module. Please contact support.</div>";
                 }
             }
         } else {
             echo "<div id=\"login\">An error occurred. Please try again.</div>";
         }