From 01f0bff142d0f9f08dc0acdc9edf805a3593d7f5 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sat, 18 Apr 2020 22:20:19 +0200 Subject: [PATCH] Removed obsolete files --- auth/.gitignore | 11 -- auth/auth.php | 250 --------------------------------------------- auth/css/auth.scss | 80 --------------- auth/js/auth.ts | 76 -------------- auth/login.php | 37 ------- 5 files changed, 454 deletions(-) delete mode 100644 auth/.gitignore delete mode 100644 auth/auth.php delete mode 100644 auth/css/auth.scss delete mode 100644 auth/js/auth.ts delete mode 100644 auth/login.php diff --git a/auth/.gitignore b/auth/.gitignore deleted file mode 100644 index df00405d..00000000 --- a/auth/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -#Nope :) -certs/ - -#A local link just for browsing the files -xf/ - -css/**/*.css -css/**/*.css.map - -js/**/*.js -js/**/*.js.map \ No newline at end of file diff --git a/auth/auth.php b/auth/auth.php deleted file mode 100644 index 1de297bf..00000000 --- a/auth/auth.php +++ /dev/null @@ -1,250 +0,0 @@ -service('XF:User\Login', $username, ""); - if (!$loginService->isLoginLimited()) { - $error = ""; - $user = $loginService->validate($password, $error); - if ($user) { - $response["success"] = true; - $allowed = false; - foreach ($allowedXFGroups as $id) { - foreach ($user->secondary_group_ids as $assigned) - if ($assigned == $id) { - $allowed = true; - break; - } - $allowed |= $user->user_group_id == $id; - if ($allowed) break; - } - if ($allowed) { - $response["allowed"] = true; - - try { - /** @var $session XF\Session\Session */ - $session = $app->session(); - if (!$session->exists()) { - $session->expunge(); - if (!$session->start(remoteAddress())) { - $response["success"] = false; - $response["msg"] = "could not create session"; - goto _return; - } - } - $session->changeUser($user); - $session->save(); - $response["sessionName"] = $session->getCookieName(); - $response["sessionId"] = $session->getSessionId(); - $response["user_name"] = $user->username; - } catch (Exception $error) { - $response["success"] = false; - $response["msg"] = $error->getMessage(); - } - goto _return; - } else { - $response["allowed"] = false; - } - } else { - $response["msg"] = $error; - } - } else { - $response["msg"] = "Too many login's!"; - } - - _return: - return $response; - } - - function logged_in() { - return test_session() == 0; - } - - function logout() - { - $app = getXF(); - if(!$app) return false; - - $session = $app->session(); - $session->expunge(); - - return true; - } - - /** - * @param null $sessionId - * @return int 0 = Success | 1 = Invalid coocie | 2 = invalid session - */ - function test_session($sessionId = null) { - $app = getXF(); - if(!$app) return -1; - - if(!isset($sessionId)) { - if (!isset($_COOKIE[$app->session()->getCookieName()])) - return 1; - $sessionId = $_COOKIE[$app->session()->getCookieName()]; - } - $app->session()->expunge(); - if (!$app->session()->start(remoteAddress(), $sessionId) || !$app->session()->exists()) - return 2; - return 0; - } - - function redirectOnInvalidSession() { - $app = getXF(); - if(!$app) return; - - $status = test_session(); - if ($status != 0) { - $type = "undefined"; - switch ($status) { - case 1: - $type = "nocookie"; - break; - case 2: - $type = "expired"; - break; - default: - $type = "unknown"; - break; - } - header('Location: ' . authPath() . 'login.php?error=' . $type); - setcookie($app->session()->getCookieName(), "", 1); - die(); - } - } - - function setup_forum_auth() { - getXF(); /* Initialize XF */ - } - - if(!defined("_AUTH_API_ONLY")) { - $app = getXF(); - if(!$app) { - die("failed to start app"); - } - - if (isset($_GET["type"])) { - error_log("Got authX request!"); - if ($_GET["type"] == "login") { - die(json_encode(checkLogin($_POST["user"], $_POST["pass"]))); - } else if ($_GET["type"] == "logout") { - logout(); - global $localhost; - if($localhost) - header("Location: login.php"); - else - header("Location: https://web.teaspeak.de/"); - - $session = $app->session(); - setcookie($session->getCookieName(), '', time() - 3600, '/'); - setcookie("session", '', time() - 3600, '/'); - setcookie("user_data", '', time() - 3600, '/'); - setcookie("user_sign", '', time() - 3600, '/'); - } else die("unknown type!"); - } else if(isset($_POST["action"])) { - error_log("Got auth post request!"); - if($_POST["action"] === "login") { - die(json_encode(checkLogin($_POST["user"], $_POST["pass"]))); - } else if ($_POST["action"] === "logout") { - logout(); - die(json_encode([ - "success" => true - ])); - } else if($_POST["action"] === "validate") { - $app = getXF(); - if(test_session($_POST["token"]) === 0) - die(json_encode([ - "success" => true, - "token" => $app->session()->getSessionId() - ])); - else - die(json_encode([ - "success" => false - ])); - } else - die(json_encode([ - "success" => false, - "msg" => "Invalid action" - ])); - } - } \ No newline at end of file diff --git a/auth/css/auth.scss b/auth/css/auth.scss deleted file mode 100644 index 07cd8efb..00000000 --- a/auth/css/auth.scss +++ /dev/null @@ -1,80 +0,0 @@ -body{ - padding:0; - margin:0; -} -.inner { - position: absolute; -} -.inner-container{ - width:400px; - height:400px; - position:absolute; - top:calc(50vh - 200px); - left:calc(50vw - 200px); - overflow:hidden; -} -.box{ - position:absolute; - height:100%; - width:100%; - font-family:Helvetica; - color:#fff; - background:rgba(0,0,0,0.13); - padding:30px 0px; - text-align: center; -} -.box h1{ - text-align:center; - margin:30px 0; - font-size:30px; -} -.box input{ - display:block; - width:300px; - margin:20px auto; - padding:15px; - background:rgba(0,0,0,0.2); - color:#fff; - border:0; -} -.box input:focus,.box input:active,.box button:focus,.box button:active{ - outline:none; -} -.box button { - background:#742ECC; - border:0; - color:#fff; - padding:10px; - font-size:20px; - width:330px; - margin:20px auto; - display:block; - cursor:pointer; -} -.box button:disabled { - background:rgba(0,0,0,0.2); -} -.box button:active{ - background:#27ae60; -} -.box p{ - font-size:14px; - text-align:center; -} -.box p span{ - cursor:pointer; - color:#666; -} - -.box .error { - color: darkred; - display: none; -} - -#login { - display: block; -} -#success { - margin-top: 50px; - display: none; -} \ No newline at end of file diff --git a/auth/js/auth.ts b/auth/js/auth.ts deleted file mode 100644 index 431bcad1..00000000 --- a/auth/js/auth.ts +++ /dev/null @@ -1,76 +0,0 @@ -const btn_login = $("#btn_login"); - -btn_login.on('click', () => { - btn_login - .prop("disabled", true) - .empty() - .append($(document.createElement("i")).addClass("fa fa-circle-o-notch fa-spin")); - submitLogin($("#user").val() as string, $("#pass").val() as string); -}); - -function submitLogin(user: string, pass: string) { - $.ajax({ - url: "auth.php?type=login", - type: "POST", - cache: false, - data: { - user: user, - pass: pass - }, - success: (result: string) => { - setTimeout(() => { - let data; - try { - data = JSON.parse(result); - } catch (e) { - loginFailed("Invalid response: " + result); - return; - } - if (data["success"] == false) { - loginFailed(data["msg"]); - return; - } - if (data["allowed"] == false) { - loginFailed("You're not allowed for the closed beta!"); - return; - } - $("#login").hide(500); - $("#success").show(500); - - document.cookie = data["sessionName"] + "=" + data["sessionId"] + ";path=/"; - document.cookie = data["cookie_name_data"] + "=" + data["user_data"] + ";path=/"; - document.cookie = data["cookie_name_sign"] + "=" + data["user_sign"] + ";path=/"; - console.log(result); - - setTimeout(() => { - window.location.href = btn_login.attr("target"); - }, 1000 + Math.random() % 1500); - }, 500 + Math.random() % 500); - }, - error: function (xhr,status,error) { - loginFailed("Invalid request (" + status + ") => " + error); - } - }); -} - -function loginFailed(err: string = "") { - btn_login - .prop("disabled", false) - .empty() - .append($(document.createElement("a")).text("Login")); - - let errTag = $(".box .error"); - if(err !== "") { - errTag.text(err).show(500); - } else errTag.hide(500); -} - -// - -$("#user").on('keydown', event => { - if(event.key == "Enter") $("#pass").focus(); -}); - -$("#pass").on('keydown', event => { - if(event.key == "Enter") $("#btn_login").trigger("click"); -}); \ No newline at end of file diff --git a/auth/login.php b/auth/login.php deleted file mode 100644 index 631108d3..00000000 --- a/auth/login.php +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - -
-
-

Login

-
- some error code - - - -

Create a account on forum.teaspeak.de

-
- -
-
- - - \ No newline at end of file