mirror of
https://git.code.sf.net/p/seeddms/code
synced 2026-01-22 09:09:15 +00:00
check for api key, getLogin() returns user object if is already exists
This commit is contained in:
parent
2f08d6bb7a
commit
8d0e8634f7
|
|
@ -20,6 +20,18 @@ if(USE_PHP_SESSION) {
|
|||
exit;
|
||||
$dms->setUser($userobj);
|
||||
} else {
|
||||
$headers = apache_request_headers();
|
||||
if(isset($headers['Authorization'])) {
|
||||
if($apikey = $dms->getApiKeyByApiKey($headers['Authorization'])) {
|
||||
if(!($userobj = $apikey->getUser())) {
|
||||
http_response_code(403);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
http_response_code(403);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
require_once("../inc/inc.ClassSession.php");
|
||||
$session = new SeedDMS_Session($db);
|
||||
if (isset($_COOKIE["mydms_session"])) {
|
||||
|
|
@ -50,6 +62,7 @@ if(USE_PHP_SESSION) {
|
|||
}
|
||||
$dms->setUser($userobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require "vendor/autoload.php";
|
||||
|
|
@ -159,6 +172,9 @@ function doLogin($request, $response) { /* {{{ */
|
|||
$username = $params['user'];
|
||||
$password = $params['pass'];
|
||||
|
||||
if($userobj)
|
||||
return $response->withJson(array('success'=>true, 'message'=>'', 'data'=>__getUserData($userobj)), 200);
|
||||
|
||||
// $userobj = $dms->getUserByLogin($username);
|
||||
$userobj = null;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user