Allow auth via Bearer token
This commit is contained in:
parent
010f976af5
commit
9b435f6fc3
1 changed files with 10 additions and 4 deletions
|
@ -684,12 +684,18 @@ function _get_user(): User
|
||||||
{
|
{
|
||||||
global $config, $page;
|
global $config, $page;
|
||||||
$my_user = null;
|
$my_user = null;
|
||||||
if ($page->get_cookie("user") && $page->get_cookie("session")) {
|
if (isset($_SERVER['HTTP_AUTHORIZATION'])) {
|
||||||
$tmp_user = User::by_session($page->get_cookie("user"), $page->get_cookie("session"));
|
$parts = explode(" ", $_SERVER['HTTP_AUTHORIZATION'], 2);
|
||||||
if (!is_null($tmp_user)) {
|
if (count($parts) == 2 && $parts[0] == "Bearer") {
|
||||||
$my_user = $tmp_user;
|
$parts = explode(":", $parts[1], 2);
|
||||||
|
if (count($parts) == 2) {
|
||||||
|
$my_user = User::by_session($parts[0], $parts[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($page->get_cookie("user") && $page->get_cookie("session")) {
|
||||||
|
$my_user = User::by_session($page->get_cookie("user"), $page->get_cookie("session"));
|
||||||
|
}
|
||||||
if (is_null($my_user)) {
|
if (is_null($my_user)) {
|
||||||
$my_user = User::by_id($config->get_int("anon_id", 0));
|
$my_user = User::by_id($config->get_int("anon_id", 0));
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue