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
mahara
mahara
Commits
1d516e17
Commit
1d516e17
authored
Sep 29, 2017
by
Robert Lyon
Committed by
Gerrit Code Review
Sep 29, 2017
Browse files
Merge "Bug 1566122: Add token set institution to user's institution"
parents
455be95e
380a44e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/webservice/admin/index.php
View file @
1d516e17
...
...
@@ -960,7 +960,9 @@ function webservice_token_submit(Pieform $form, $values) {
else
{
// just pass the first one for the moment
$service
=
array_shift
(
$services
);
$token
=
webservice_generate_token
(
EXTERNAL_TOKEN_PERMANENT
,
$service
,
$dbuser
->
id
);
$auth_instance
=
webservice_validate_user
(
$dbuser
);
$institution
=
$auth_instance
?
$auth_instance
->
institution
:
'mahara'
;
$token
=
webservice_generate_token
(
EXTERNAL_TOKEN_PERMANENT
,
$service
,
$dbuser
->
id
,
$institution
);
$dbtoken
=
get_record
(
'external_tokens'
,
'token'
,
$token
);
redirect
(
'/webservice/admin/tokenconfig.php?token='
.
$dbtoken
->
id
);
}
...
...
htdocs/webservice/lib.php
View file @
1d516e17
...
...
@@ -149,8 +149,15 @@ function mahara_external_atom_returns() {
function
webservice_validate_user
(
$dbuser
)
{
global
$SESSION
;
if
(
!
empty
(
$dbuser
))
{
$auth_instance
=
get_record
(
'auth_instance'
,
'id'
,
$dbuser
->
authinstance
,
'active'
,
1
);
if
(
$auth_instance
->
authname
==
'webservice'
)
{
if
(
$auth_instance
=
get_record_sql
(
"SELECT * FROM
{
auth_instance
}
WHERE authname = 'webservice'
AND active = 1
AND institution = (
SELECT institution FROM
{
auth_instance
}
WHERE id = ?
AND active = 1
)"
,
array
(
$dbuser
->
authinstance
)))
{
// User belongs to an institution that contains the 'webservice' auth method
$memberships
=
count_records
(
'usr_institution'
,
'usr'
,
$dbuser
->
id
);
if
(
$memberships
==
0
)
{
// auth instance should be a mahara one
...
...
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