MDL-67749 ws: Set private token when reset or manual create token

This commit is contained in:
Dani Palou
2020-02-19 12:03:48 +01:00
parent 2c0b08c5a7
commit 956232db1d
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -773,7 +773,8 @@ function external_generate_token($tokentype, $serviceorid, $userid, $contextorid
if (!empty($iprestriction)) {
$newtoken->iprestriction = $iprestriction;
}
$newtoken->privatetoken = null;
// Generate the private token, it must be transmitted only via https.
$newtoken->privatetoken = random_string(64);
$DB->insert_record('external_tokens', $newtoken);
return $newtoken->token;
}
+2 -1
View File
@@ -370,7 +370,8 @@ class webservice {
$newtoken->contextid = context_system::instance()->id;
$newtoken->creatorid = $userid;
$newtoken->timecreated = time();
$newtoken->privatetoken = null;
// Generate the private token, it must be transmitted only via https.
$newtoken->privatetoken = random_string(64);
$DB->insert_record('external_tokens', $newtoken);
}