add ajax action to get csrf token (for external authentication)

This commit is contained in:
Max Pozdeev 2022-02-16 23:10:43 +03:00
parent 4a41ad0467
commit 291708692b

View file

@ -309,7 +309,7 @@ elseif(isset($_POST['login']))
}
if ( isPasswordEqualsToHash(_post('password'), Config::get('password')) ) {
updateSessionLogged(true);
update_token();
$t['token'] = update_token();
$t['logged'] = 1;
}
jsonExit($t);
@ -541,6 +541,23 @@ elseif(isset($_GET['setHideList']))
}
jsonExit(array('total'=>1));
}
elseif (isset($_POST['createSession']))
{
$t = array();
if (!need_auth()) {
$t['disabled'] = 1;
jsonExit($t);
}
if (access_token() == '') {
update_token();
}
$t['token'] = access_token();
$t['session'] = session_id();
jsonExit($t);
}
else {
jsonExit(['total' => 0]);
}
###################################################################################################