mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-78637 webservice: display token info after user performs reset.
This commit is contained in:
parent
8dbb6183ff
commit
686b054b78
@ -57,6 +57,15 @@ if ( !is_siteadmin($USER->id)
|
||||
// Delete the token that need to be regenerated.
|
||||
require_sesskey();
|
||||
$webservice->delete_user_ws_token($tokenid);
|
||||
|
||||
// Now re-create one against the same service.
|
||||
\core_external\util::generate_token(
|
||||
EXTERNAL_TOKEN_PERMANENT,
|
||||
\core_external\util::get_service_by_id($token->externalserviceid),
|
||||
$USER->id,
|
||||
context_system::instance()
|
||||
);
|
||||
|
||||
redirect($PAGE->url, get_string('resettokencomplete', 'core_webservice'));
|
||||
}
|
||||
}
|
||||
@ -108,6 +117,23 @@ echo $OUTPUT->header();
|
||||
if (!empty($resetconfirmation)) {
|
||||
echo $resetconfirmation;
|
||||
} else {
|
||||
|
||||
if (!empty($SESSION->webservicenewlycreatedtoken)) {
|
||||
$webservicemanager = new webservice();
|
||||
$newtoken = $webservicemanager->get_created_by_user_ws_token(
|
||||
$USER->id,
|
||||
$SESSION->webservicenewlycreatedtoken
|
||||
);
|
||||
if ($newtoken) {
|
||||
// Unset the session variable.
|
||||
unset($SESSION->webservicenewlycreatedtoken);
|
||||
// Display the newly created token.
|
||||
echo $OUTPUT->render_from_template(
|
||||
'core_admin/webservice_token_new', ['token' => $newtoken->token, 'tokenname' => $newtoken->tokenname]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
echo $webservicetokenboxhtml;
|
||||
echo $rsstokenboxhtml;
|
||||
}
|
||||
|
@ -413,8 +413,10 @@ class webservice {
|
||||
* The returned value is a stdClass:
|
||||
* ->id token id
|
||||
* ->token
|
||||
* ->tokenname
|
||||
* ->firstname user firstname
|
||||
* ->lastname
|
||||
* ->externalserviceid
|
||||
* ->name service name
|
||||
*
|
||||
* @param int $userid user id
|
||||
@ -424,7 +426,7 @@ class webservice {
|
||||
public function get_created_by_user_ws_token($userid, $tokenid) {
|
||||
global $DB;
|
||||
$sql = "SELECT
|
||||
t.id, t.token, t.name AS tokenname, u.firstname, u.lastname, s.name
|
||||
t.id, t.token, t.name AS tokenname, u.firstname, u.lastname, t.externalserviceid, s.name
|
||||
FROM
|
||||
{external_tokens} t, {user} u, {external_services} s
|
||||
WHERE
|
||||
|
Loading…
x
Reference in New Issue
Block a user