Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
GLPI
glpi
Commits
fa6a7b6a
Commit
fa6a7b6a
authored
Oct 02, 2019
by
Thierry Bugier
Committed by
Johan Cwiklinski
Oct 03, 2019
Browse files
give the ID of the user after init session
Signed-off-by:
Thierry Bugier
<
tbugier@teclib.com
>
parent
bc294cf7
Changes
5
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
fa6a7b6a
...
...
@@ -20,6 +20,7 @@ The present file will list all changes made to the project; according to the
-
Add and answer approvals from timeline
-
Add lightbox with PhotoSwipe to timeline images
-
Ability to copy tasks while merging tickets
-
the API gives the ID of the user who logs in with initSession
### Changed
...
...
apirest.md
View file @
fa6a7b6a
...
...
@@ -116,7 +116,7 @@ App(lication) token
*
"Authorization: user_token q56hqkniwot8wntb3z1qarka5atf365taaa2uyjrn"
*
**Returns**
:
*
200 (OK) with the
*session_token*
string.
*
200 (OK) with the
*session_token*
string
and the
*ID of the logged in user*
.
*
400 (Bad Request) with a message indicating an error in input parameter.
*
401 (UNAUTHORIZED)
...
...
@@ -131,7 +131,8 @@ $ curl -X GET \
< 200 OK
<
{
"session_token"
:
"83af7e620c83a50a18d3eac2f6ed05a3ca0bea62"
"session_token"
:
"83af7e620c83a50a18d3eac2f6ed05a3ca0bea62"
,
"users_id"
:
"42"
}
$
curl
-X
GET
\
...
...
@@ -142,7 +143,8 @@ $ curl -X GET \
< 200 OK
<
{
"session_token"
:
"83af7e620c83a50a18d3eac2f6ed05a3ca0bea62"
"session_token"
:
"83af7e620c83a50a18d3eac2f6ed05a3ca0bea62"
,
"users_id"
:
"42"
}
```
...
...
inc/api.class.php
View file @
fa6a7b6a
...
...
@@ -249,7 +249,10 @@ abstract class API extends CommonGLPI {
// stop session and return session key
session_write_close
();
return
[
'session_token'
=>
$_SESSION
[
'valid_id'
]];
return
[
'session_token'
=>
$_SESSION
[
'valid_id'
],
'users_id'
=>
Session
::
getLoginUserID
(),
];
}
...
...
tests/web/APIRest.php
View file @
fa6a7b6a
...
...
@@ -215,6 +215,8 @@ class APIRest extends APIBaseClass {
$data
=
json_decode
(
$body
,
true
);
$this
->
variable
(
$data
)
->
isNotFalse
();
$this
->
array
(
$data
)
->
hasKey
(
'session_token'
);
$this
->
array
(
$data
)
->
hasKey
(
'users_id'
);
$this
->
integer
((
int
)
$data
[
'users_id'
])
->
isEqualTo
(
$uid
);
}
/**
...
...
tests/web/APIXmlrpc.php
View file @
fa6a7b6a
...
...
@@ -106,6 +106,7 @@ class APIXmlrpc extends APIBaseClass {
* @covers API::initSession
*/
public
function
initSessionCredentials
()
{
$uid
=
getItemByTypeName
(
'User'
,
TU_USER
,
true
);
$data
=
$this
->
query
(
'initSession'
,
[
'query'
=>
[
'login'
=>
TU_USER
,
...
...
@@ -114,6 +115,8 @@ class APIXmlrpc extends APIBaseClass {
$this
->
variable
(
$data
)
->
isNotFalse
();
$this
->
array
(
$data
)
->
hasKey
(
'session_token'
);
$this
->
session_token
=
$data
[
'session_token'
];
$this
->
array
(
$data
)
->
hasKey
(
'users_id'
);
$this
->
integer
((
int
)
$data
[
'users_id'
])
->
isEqualTo
(
$uid
);
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment