forked from Business/ManagePanel
Merge BusinessAppTemplate
# Conflicts: # lib/User.lib.php # pages/form.php
This commit is contained in:
commit
be00440f58
@ -55,25 +55,23 @@ function authenticate(): bool {
|
|||||||
global $VARS;
|
global $VARS;
|
||||||
// HTTP basic auth
|
// HTTP basic auth
|
||||||
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
|
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
|
||||||
$user = User::byUsername($_SERVER['PHP_AUTH_USER']);
|
$username = $_SERVER['PHP_AUTH_USER'];
|
||||||
if (!$user->checkPassword($_SERVER['PHP_AUTH_PW'])) {
|
$password = $_SERVER['PHP_AUTH_PW'];
|
||||||
return false;
|
} else if (!empty($VARS['username']) && !empty($VARS['password'])) {
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Form auth
|
|
||||||
if (empty($VARS['username']) || empty($VARS['password'])) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
$username = $VARS['username'];
|
$username = $VARS['username'];
|
||||||
$password = $VARS['password'];
|
$password = $VARS['password'];
|
||||||
$user = User::byUsername($username);
|
} else {
|
||||||
if ($user->exists() !== true || Login::auth($username, $password) !== Login::LOGIN_OK) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
$user = User::byUsername($username);
|
||||||
|
if (!$user->exists()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
if ($user->checkPassword($password, true)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the User whose credentials were used to make the request.
|
* Get the User whose credentials were used to make the request.
|
||||||
|
@ -10,6 +10,8 @@ require __DIR__ . '/../required.php';
|
|||||||
require __DIR__ . '/functions.php';
|
require __DIR__ . '/functions.php';
|
||||||
require __DIR__ . '/apisettings.php';
|
require __DIR__ . '/apisettings.php';
|
||||||
|
|
||||||
|
header("Access-Control-Allow-Origin: *");
|
||||||
|
|
||||||
$VARS = $_GET;
|
$VARS = $_GET;
|
||||||
if ($_SERVER['REQUEST_METHOD'] != "GET") {
|
if ($_SERVER['REQUEST_METHOD'] != "GET") {
|
||||||
$VARS = array_merge($VARS, $_POST);
|
$VARS = array_merge($VARS, $_POST);
|
||||||
|
@ -178,7 +178,10 @@ HTMLTOP;
|
|||||||
}
|
}
|
||||||
$itemhtml = "";
|
$itemhtml = "";
|
||||||
$itemlabel = "";
|
$itemlabel = "";
|
||||||
if ($item['type'] != "checkbox") {
|
|
||||||
|
if ($item['type'] == "textarea") {
|
||||||
|
$itemlabel = "<label class=\"mb-0\"><i class=\"$item[icon]\"></i> $item[label]:</label>";
|
||||||
|
} else if ($item['type'] != "checkbox") {
|
||||||
$itemlabel = "<label class=\"mb-0\">$item[label]:</label>";
|
$itemlabel = "<label class=\"mb-0\">$item[label]:</label>";
|
||||||
}
|
}
|
||||||
$strippedlabel = strip_tags($item['label']);
|
$strippedlabel = strip_tags($item['label']);
|
||||||
@ -186,13 +189,16 @@ HTMLTOP;
|
|||||||
\n\n <div class="col-12 col-md-$item[width]">
|
\n\n <div class="col-12 col-md-$item[width]">
|
||||||
<div class="form-group mb-3">
|
<div class="form-group mb-3">
|
||||||
$itemlabel
|
$itemlabel
|
||||||
<div class="input-group">
|
ITEMTOP;
|
||||||
|
$inputgrouptop = <<<INPUTG
|
||||||
|
\n <div class="input-group">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text"><i class="$item[icon]"></i></span>
|
<span class="input-group-text"><i class="$item[icon]"></i></span>
|
||||||
</div>
|
</div>
|
||||||
ITEMTOP;
|
INPUTG;
|
||||||
switch ($item['type']) {
|
switch ($item['type']) {
|
||||||
case "select":
|
case "select":
|
||||||
|
$itemhtml .= $inputgrouptop;
|
||||||
$itemhtml .= <<<SELECT
|
$itemhtml .= <<<SELECT
|
||||||
\n <select class="form-control" name="$item[name]" aria-label="$strippedlabel" $required>
|
\n <select class="form-control" name="$item[name]" aria-label="$strippedlabel" $required>
|
||||||
SELECT;
|
SELECT;
|
||||||
@ -206,6 +212,7 @@ SELECT;
|
|||||||
$itemhtml .= "\n </select>";
|
$itemhtml .= "\n </select>";
|
||||||
break;
|
break;
|
||||||
case "checkbox":
|
case "checkbox":
|
||||||
|
$itemhtml .= $inputgrouptop;
|
||||||
$itemhtml .= <<<CHECKBOX
|
$itemhtml .= <<<CHECKBOX
|
||||||
\n <div class="form-group form-check">
|
\n <div class="form-group form-check">
|
||||||
<input type="checkbox" name="$item[name]" $id class="form-check-input" value="$item[value]" $required aria-label="$strippedlabel">
|
<input type="checkbox" name="$item[name]" $id class="form-check-input" value="$item[value]" $required aria-label="$strippedlabel">
|
||||||
@ -213,7 +220,14 @@ SELECT;
|
|||||||
</div>
|
</div>
|
||||||
CHECKBOX;
|
CHECKBOX;
|
||||||
break;
|
break;
|
||||||
|
case "textarea":
|
||||||
|
$val = htmlentities($item['value']);
|
||||||
|
$itemhtml .= <<<TEXTAREA
|
||||||
|
\n <textarea class="form-control" id="info" name="$item[name]" aria-label="$strippedlabel" minlength="$item[minlength]" maxlength="$item[maxlength]" $required>$val</textarea>
|
||||||
|
TEXTAREA;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
|
$itemhtml .= $inputgrouptop;
|
||||||
$itemhtml .= <<<INPUT
|
$itemhtml .= <<<INPUT
|
||||||
\n <input type="$item[type]" name="$item[name]" $id class="form-control" aria-label="$strippedlabel" minlength="$item[minlength]" maxlength="$item[maxlength]" $pattern value="$item[value]" $required />
|
\n <input type="$item[type]" name="$item[name]" $id class="form-control" aria-label="$strippedlabel" minlength="$item[minlength]" maxlength="$item[maxlength]" $pattern value="$item[value]" $required />
|
||||||
INPUT;
|
INPUT;
|
||||||
@ -227,9 +241,11 @@ INPUT;
|
|||||||
</div>
|
</div>
|
||||||
ERROR;
|
ERROR;
|
||||||
}
|
}
|
||||||
|
if ($item["type"] != "textarea") {
|
||||||
|
$itemhtml .= "\n </div>";
|
||||||
|
}
|
||||||
$itemhtml .= <<<ITEMBOTTOM
|
$itemhtml .= <<<ITEMBOTTOM
|
||||||
\n </div>
|
\n </div>
|
||||||
</div>
|
|
||||||
</div>\n
|
</div>\n
|
||||||
ITEMBOTTOM;
|
ITEMBOTTOM;
|
||||||
$html .= $itemhtml;
|
$html .= $itemhtml;
|
||||||
@ -242,7 +258,7 @@ ITEMBOTTOM;
|
|||||||
HTMLBOTTOM;
|
HTMLBOTTOM;
|
||||||
|
|
||||||
if (!empty($this->buttons)) {
|
if (!empty($this->buttons)) {
|
||||||
$html .= "\n <div class=\"card-footer\">";
|
$html .= "\n <div class=\"card-footer d-flex\">";
|
||||||
foreach ($this->buttons as $btn) {
|
foreach ($this->buttons as $btn) {
|
||||||
$btnhtml = "";
|
$btnhtml = "";
|
||||||
$inner = "<i class=\"$btn[icon]\"></i> $btn[text]";
|
$inner = "<i class=\"$btn[icon]\"></i> $btn[text]";
|
||||||
|
@ -101,10 +101,16 @@ class User {
|
|||||||
/**
|
/**
|
||||||
* Check the given plaintext password against the stored hash.
|
* Check the given plaintext password against the stored hash.
|
||||||
* @param string $password
|
* @param string $password
|
||||||
|
* @param bool $apppass Set to true to enforce app passwords when 2fa is on.
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function checkPassword(string $password): bool {
|
function checkPassword(string $password, bool $apppass = false): bool {
|
||||||
return password_verify($password, $this->passhash);
|
$resp = AccountHubApi::get("auth", ['username' => $this->username, 'password' => $password, 'apppass' => ($apppass ? "1" : "0")]);
|
||||||
|
if ($resp['status'] == "OK") {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user