Some memory updates
This commit is contained in:
parent
1c67d6a682
commit
03f37eca62
13 changed files with 159 additions and 47 deletions
|
@ -104,9 +104,9 @@
|
||||||
/**
|
/**
|
||||||
* @param $username
|
* @param $username
|
||||||
* @param $password
|
* @param $password
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function checkLogin($username, $password)
|
function checkLogin($username, $password) {
|
||||||
{
|
|
||||||
$allowedXFGroups = [
|
$allowedXFGroups = [
|
||||||
3, //Administrator
|
3, //Administrator
|
||||||
6, //Web tester
|
6, //Web tester
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
$response["success"] = false;
|
$response["success"] = false;
|
||||||
|
|
||||||
if (!isset($username) || !isset($password)) {
|
if (!isset($username) || !isset($password)) {
|
||||||
$response["msg"] = "missing credicals";
|
$response["msg"] = "missing credentials";
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +165,8 @@
|
||||||
$response["user_data"] = $user_data["data"];
|
$response["user_data"] = $user_data["data"];
|
||||||
$response["user_sign"] = $user_data["sign"];
|
$response["user_sign"] = $user_data["sign"];
|
||||||
} catch (Exception $error) {
|
} catch (Exception $error) {
|
||||||
die($error);
|
$response["success"] = false;
|
||||||
|
$response["msg"] = $error->getMessage();
|
||||||
}
|
}
|
||||||
goto _return;
|
goto _return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,15 +176,15 @@
|
||||||
$response["msg"] = $error;
|
$response["msg"] = $error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$response["msg"] = "To many login's!";
|
$response["msg"] = "Too many login's!";
|
||||||
}
|
}
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
die(json_encode($response));
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
function logged_in() {
|
function logged_in() {
|
||||||
return testSession() == 0;
|
return test_session() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout()
|
function logout()
|
||||||
|
@ -192,24 +193,20 @@
|
||||||
$session = $app->session();
|
$session = $app->session();
|
||||||
$session->expunge();
|
$session->expunge();
|
||||||
|
|
||||||
global $localhost;
|
return true;
|
||||||
if($localhost)
|
|
||||||
header("Location: login.php");
|
|
||||||
else
|
|
||||||
header("Location: https://web.teaspeak.de/");
|
|
||||||
setcookie($session->getCookieName(), '', time() - 3600, '/');
|
|
||||||
setcookie("session", '', time() - 3600, '/');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int 0 = Success | 1 = Invalid coocie | 2 = invalid session
|
* @return int 0 = Success | 1 = Invalid coocie | 2 = invalid session
|
||||||
*/
|
*/
|
||||||
function testSession()
|
function test_session($sessionId = null)
|
||||||
{
|
{
|
||||||
$app = getXF();
|
$app = getXF();
|
||||||
if (!isset($_COOKIE[$app->session()->getCookieName()]))
|
if(!isset($sessionId)) {
|
||||||
return 1;
|
if (!isset($_COOKIE[$app->session()->getCookieName()]))
|
||||||
$sessionId = $_COOKIE[$app->session()->getCookieName()];
|
return 1;
|
||||||
|
$sessionId = $_COOKIE[$app->session()->getCookieName()];
|
||||||
|
}
|
||||||
$app->session()->expunge();
|
$app->session()->expunge();
|
||||||
if (!$app->session()->start(remoteAddress(), $sessionId) || !$app->session()->exists())
|
if (!$app->session()->start(remoteAddress(), $sessionId) || !$app->session()->exists())
|
||||||
return 2;
|
return 2;
|
||||||
|
@ -219,7 +216,7 @@
|
||||||
function redirectOnInvalidSession()
|
function redirectOnInvalidSession()
|
||||||
{
|
{
|
||||||
$app = getXF();
|
$app = getXF();
|
||||||
$status = testSession();
|
$status = test_session();
|
||||||
if ($status != 0) {
|
if ($status != 0) {
|
||||||
$type = "undefined";
|
$type = "undefined";
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
|
@ -245,11 +242,41 @@
|
||||||
var_dump($_GET);
|
var_dump($_GET);
|
||||||
var_dump($_POST);
|
var_dump($_POST);
|
||||||
if ($_GET["type"] == "login") {
|
if ($_GET["type"] == "login") {
|
||||||
checkLogin($_POST["user"], $_POST["pass"]);
|
die(checkLogin($_POST["user"], $_POST["pass"]));
|
||||||
} else if ($_GET["type"] == "logout") {
|
} else if ($_GET["type"] == "logout") {
|
||||||
logout();
|
logout();
|
||||||
|
global $localhost;
|
||||||
|
if($localhost)
|
||||||
|
header("Location: login.php");
|
||||||
|
else
|
||||||
|
header("Location: https://web.teaspeak.de/");
|
||||||
|
setcookie($session->getCookieName(), '', time() - 3600, '/');
|
||||||
|
setcookie("session", '', time() - 3600, '/');
|
||||||
} else die("unknown type!");
|
} else die("unknown type!");
|
||||||
} else if(isset($_POST)) {
|
} else if(isset($_POST)) {
|
||||||
error_log("Got auth request!");
|
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"
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
include_once('auth.php');
|
include_once('auth.php');
|
||||||
$session = testSession();
|
$session = test_session();
|
||||||
if($session == 0) {
|
if($session == 0) {
|
||||||
header('Location: ' . mainPath() . 'index.php');
|
header('Location: ' . mainPath() . 'index.php');
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
9
client/app-definitions/teaforo/manager.d.ts
vendored
Normal file
9
client/app-definitions/teaforo/manager.d.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
export interface UserData {
|
||||||
|
session_id: string;
|
||||||
|
username: string;
|
||||||
|
application_data: string;
|
||||||
|
application_data_sign: string;
|
||||||
|
}
|
||||||
|
export declare function open_login(enforce?: boolean): Promise<UserData>;
|
||||||
|
export declare function current_data(): UserData | undefined;
|
||||||
|
export declare function logout(): void;
|
25
client/js/teaforo.ts
Normal file
25
client/js/teaforo.ts
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
import {UserData} from "../app-definitions/teaforo/manager";
|
||||||
|
|
||||||
|
const ipc = require("electron").ipcRenderer;
|
||||||
|
let callback_listener: (() => any)[] = [];
|
||||||
|
|
||||||
|
ipc.on('teaforo-update', (event, data: UserData) => {
|
||||||
|
console.log("Got data update: %o", data);
|
||||||
|
forumIdentity = data ? new TeaForumIdentity(data.application_data, data.application_data_sign) : undefined;
|
||||||
|
try {
|
||||||
|
for(let listener of callback_listener)
|
||||||
|
setImmediate(listener);
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback_listener = [];
|
||||||
|
});
|
||||||
|
|
||||||
|
export function register_callback(callback: () => any) {
|
||||||
|
callback_listener.push(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function open() {
|
||||||
|
ipc.send("teaforo-login");
|
||||||
|
}
|
|
@ -86,6 +86,15 @@
|
||||||
"path" => "css/",
|
"path" => "css/",
|
||||||
"local-path" => "./client/css/"
|
"local-path" => "./client/css/"
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
"client-only" => true,
|
||||||
|
"type" => "js",
|
||||||
|
"search-pattern" => "/.*\.js/",
|
||||||
|
"build-target" => "dev|rel",
|
||||||
|
|
||||||
|
"path" => "js/",
|
||||||
|
"local-path" => "./client/js/"
|
||||||
|
],
|
||||||
|
|
||||||
/* web specs */
|
/* web specs */
|
||||||
[
|
[
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
function logged_in() {
|
function logged_in() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$localhost = true;
|
|
||||||
}
|
}
|
||||||
$localhost |= gethostname() == "WolverinDEV";
|
$localhost |= gethostname() == "WolverinDEV";
|
||||||
if (!$localhost || $testXF) {
|
if (!$localhost || $testXF) {
|
||||||
|
@ -87,6 +85,9 @@
|
||||||
gtag('config', 'UA-113151733-4');
|
gtag('config', 'UA-113151733-4');
|
||||||
</script>
|
</script>
|
||||||
<script src="vendor/jquery/jquery.min.js"></script>
|
<script src="vendor/jquery/jquery.min.js"></script>
|
||||||
|
<script>
|
||||||
|
//const exports = {};
|
||||||
|
</script>
|
||||||
<div id="scripts">
|
<div id="scripts">
|
||||||
<script type="application/javascript" src="js/load.js" defer></script>
|
<script type="application/javascript" src="js/load.js" defer></script>
|
||||||
</div>
|
</div>
|
||||||
|
|
12
package.json
12
package.json
|
@ -3,9 +3,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Welcome here! This repository is created with two reasons:\n 1. People can bring their own ideas and follow their implementation\n 2. People can see TeaSpeak Web client progress and avoid creating repetitive issues all the time.",
|
"description": "Welcome here! This repository is created with two reasons:\n 1. People can bring their own ideas and follow their implementation\n 2. People can see TeaSpeak Web client progress and avoid creating repetitive issues all the time.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"directories": {
|
"directories": {},
|
||||||
|
|
||||||
},
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build-web-app": "tsc -p tsconfig/tsconfig_web_app.json",
|
"build-web-app": "tsc -p tsconfig/tsconfig_web_app.json",
|
||||||
"build-web-app-release": "tsc -p tsconfig/tsconfig_web_app_packaged.json",
|
"build-web-app-release": "tsc -p tsconfig/tsconfig_web_app_packaged.json",
|
||||||
|
@ -14,13 +12,13 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^9.4.6",
|
|
||||||
"@types/emscripten": "0.0.31",
|
"@types/emscripten": "0.0.31",
|
||||||
"@types/jquery": "^3.3.0",
|
"@types/jquery": "^3.3.0",
|
||||||
"@types/websocket": "0.0.38"
|
"@types/node": "^9.4.6",
|
||||||
},
|
"@types/websocket": "0.0.38",
|
||||||
"dependencies": {
|
"electron": "^3.0.2"
|
||||||
},
|
},
|
||||||
|
"dependencies": {},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/TeaSpeak/TeaWeb/TeaWeb.git"
|
"url": "git+https://github.com/TeaSpeak/TeaWeb/TeaWeb.git"
|
||||||
|
|
|
@ -243,8 +243,9 @@ function loadTemplates() {
|
||||||
function loadSide() {
|
function loadSide() {
|
||||||
if(window.require !== undefined) {
|
if(window.require !== undefined) {
|
||||||
console.log("Loading node specific things");
|
console.log("Loading node specific things");
|
||||||
const app = require('electron').remote.app;
|
const remote = require('electron').remote;
|
||||||
module.paths.push(app.getAppPath());
|
module.paths.push(remote.app.getAppPath());
|
||||||
|
module.paths.push(remote.getGlobal("browser-root") + "js/");
|
||||||
window.$ = require("assets/jquery.min.js");
|
window.$ = require("assets/jquery.min.js");
|
||||||
require("native/loader_adapter.js");
|
require("native/loader_adapter.js");
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,10 @@ function main() {
|
||||||
displayCriticalError("Missing jsrender extension!");
|
displayCriticalError("Missing jsrender extension!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!js_render.views) {
|
||||||
|
displayCriticalError("Missing jsrender viewer extension!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
js_render.views.settings.allowCode(true);
|
js_render.views.settings.allowCode(true);
|
||||||
js_render.views.tags("rnd", (argument) => {
|
js_render.views.tags("rnd", (argument) => {
|
||||||
let min = parseInt(argument.substr(0, argument.indexOf('~')));
|
let min = parseInt(argument.substr(0, argument.indexOf('~')));
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/// <reference path="../../utils/modal.ts" />
|
/// <reference path="../../utils/modal.ts" />
|
||||||
|
|
||||||
namespace Modals {
|
namespace Modals {
|
||||||
export function spawnConnectModal(defaultHost: string = "ts.TeaSpeak.de", def_connect_type?: IdentitifyType) {
|
export function spawnConnectModal(defaultHost: string = "ts.TeaSpeak.de", def_connect_type?: IdentitifyType) {
|
||||||
let connectIdentity: Identity;
|
let connectIdentity: Identity;
|
||||||
|
@ -10,6 +11,7 @@ namespace Modals {
|
||||||
},
|
},
|
||||||
body: function () {
|
body: function () {
|
||||||
let tag = $("#tmpl_connect").renderTag({
|
let tag = $("#tmpl_connect").renderTag({
|
||||||
|
client: native_client,
|
||||||
forum_path: settings.static("forum_path"),
|
forum_path: settings.static("forum_path"),
|
||||||
forum_valid: !!forumIdentity
|
forum_valid: !!forumIdentity
|
||||||
});
|
});
|
||||||
|
@ -110,10 +112,38 @@ namespace Modals {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
tag.find(".identity_config_" + IdentitifyType[IdentitifyType.TEAFORO]).on('shown', ev => {
|
const element = tag.find(".identity_config_" + IdentitifyType[IdentitifyType.TEAFORO]);
|
||||||
|
element.on('shown', ev => {
|
||||||
|
console.log("Updating via shown");
|
||||||
connectIdentity = forumIdentity;
|
connectIdentity = forumIdentity;
|
||||||
|
|
||||||
|
if(connectIdentity) {
|
||||||
|
element.find(".connected").show();
|
||||||
|
element.find(".disconnected").hide();
|
||||||
|
} else {
|
||||||
|
element.find(".connected").hide();
|
||||||
|
element.find(".disconnected").show();
|
||||||
|
}
|
||||||
updateFields();
|
updateFields();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(native_client) {
|
||||||
|
tag.find(".native-teaforo-login").on('click', event => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const forum = require("teaforo.js");
|
||||||
|
const call = () => {
|
||||||
|
try {
|
||||||
|
console.log("Trigger update!");
|
||||||
|
element.trigger('shown');
|
||||||
|
} catch ($) { console.log($); }
|
||||||
|
if(connectModal.shown)
|
||||||
|
forum.register_callback(call);
|
||||||
|
};
|
||||||
|
forum.register_callback(call);
|
||||||
|
forum.open();
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -125,8 +155,11 @@ namespace Modals {
|
||||||
if(connectIdentity instanceof NameIdentity)
|
if(connectIdentity instanceof NameIdentity)
|
||||||
connectIdentity.set_name(tag.find(".connect_nickname").val() as string);
|
connectIdentity.set_name(tag.find(".connect_nickname").val() as string);
|
||||||
});
|
});
|
||||||
if(!settings.static("localhost_debug", false))
|
|
||||||
|
if(!settings.static("localhost_debug", false)) {
|
||||||
|
console.trace("Removing debug connect option");
|
||||||
tag.find(".identity_select option[value=" + IdentitifyType[IdentitifyType.NICKNAME] + "]").remove();
|
tag.find(".identity_select option[value=" + IdentitifyType[IdentitifyType.NICKNAME] + "]").remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//connect_address
|
//connect_address
|
||||||
|
|
|
@ -74,9 +74,11 @@ class ModalProperties {
|
||||||
class Modal {
|
class Modal {
|
||||||
private _htmlTag: JQuery;
|
private _htmlTag: JQuery;
|
||||||
properties: ModalProperties;
|
properties: ModalProperties;
|
||||||
|
shown: boolean;
|
||||||
|
|
||||||
constructor(props: ModalProperties) {
|
constructor(props: ModalProperties) {
|
||||||
this.properties = props;
|
this.properties = props;
|
||||||
|
this.shown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get htmlTag() : JQuery {
|
get htmlTag() : JQuery {
|
||||||
|
@ -113,11 +115,13 @@ class Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
open() {
|
open() {
|
||||||
|
this.shown = true;
|
||||||
this.htmlTag.appendTo($("body"));
|
this.htmlTag.appendTo($("body"));
|
||||||
this.htmlTag.show();
|
this.htmlTag.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
this.shown = false;
|
||||||
const _this = this;
|
const _this = this;
|
||||||
this.htmlTag.animate({opacity: 0}, () => {
|
this.htmlTag.animate({opacity: 0}, () => {
|
||||||
_this.htmlTag.detach();
|
_this.htmlTag.detach();
|
||||||
|
|
|
@ -135,13 +135,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="identity_config_TEAFORO identity_config">
|
<div class="identity_config_TEAFORO identity_config">
|
||||||
{{if forum_valid}}
|
<div class="connected">
|
||||||
You're using your forum account as verification
|
You're using your forum account as verification
|
||||||
{{else}}
|
</div>
|
||||||
You cant use your TeaSpeak forum account.<br>
|
<div class="disconnected">
|
||||||
You're not connected!<br>
|
You cant use your TeaSpeak forum account.<br>
|
||||||
Click <a href="{{:forum_path}}login.php">here</a> to login via the TeaSpeak forum.
|
You're not connected!<br>
|
||||||
{{/if}}
|
Click {{if !client}}<a href="{{:forum_path}}login.php">here</a>{{else}}<a href="#" class="native-teaforo-login">here</a>{{/if}} to login via the TeaSpeak forum.
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="identity_config_NICKNAME identity_config">
|
<div class="identity_config_NICKNAME identity_config">
|
||||||
This is just for debug and uses the name as unique identifier
|
This is just for debug and uses the name as unique identifier
|
||||||
|
|
Loading…
Add table
Reference in a new issue