Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-28670 webservice : added dimming of service name in security keys…

… page if webservice is disabled or not on authorised list to access webservice.
  • Loading branch information...
commit b062b305f1c94ef7ef1466710ada6e5a9abcaff6 1 parent 919e659
@nebgor nebgor authored
View
8 user/managetoken.php
@@ -66,7 +66,13 @@
if (empty($resetconfirmation)) {
$webservice->generate_user_ws_tokens($USER->id); //generate all token that need to be generated
$tokens = $webservice->get_user_ws_tokens($USER->id);
- $webservicetokenboxhtml = $wsrenderer->user_webservice_tokens_box($tokens, $USER->id,
+ foreach ($tokens as $token) {
+ $authlist = $webservice->get_ws_authorised_user($token->wsid, $USER->id);
+ if(empty($authlist) && $token->restrictedusers) {
+ $token->enabled = false;
+ }
+ }
+ $webservicetokenboxhtml = $wsrenderer->user_webservice_tokens_box($tokens, $USER->id,
$CFG->enablewsdocumentation); //display the box for web service token
}
}
View
4 webservice/lib.php
@@ -165,7 +165,7 @@ public function generate_user_ws_tokens($userid) {
}
/**
- * Return all ws user token
+ * Return all ws user token with ws enabled/disabled and ws restricted users mode.
* @param integer $userid
* @return array of token
*/
@@ -173,7 +173,7 @@ public function get_user_ws_tokens($userid) {
global $DB;
//here retrieve token list (including linked users firstname/lastname and linked services name)
$sql = "SELECT
- t.id, t.creatorid, t.token, u.firstname, u.lastname, s.name, t.validuntil
+ t.id, t.creatorid, t.token, u.firstname, u.lastname, s.id as wsid, s.name, s.enabled, s.restrictedusers, t.validuntil
FROM
{external_tokens} t, {user} u, {external_services} s
WHERE
View
3  webservice/renderer.php
@@ -320,6 +320,9 @@ public function user_webservice_tokens_box($tokens, $userid, $documentation = fa
$validuntil = date("F j, Y"); //TODO: language support (look for moodle function)
}
+ if (!$token->enabled) { //that is the (1 token-1ws) related ws is not enabled.
+ $token->name = '<span class="dimmed_text">'.$token->name.'</span>';
+ }
$row = array($token->token, $token->name, $validuntil, $creatoratag, $reset);
if ($documentation) {
Please sign in to comment.
Something went wrong with that request. Please try again.