mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
webservice MDL-21351 token error message more explicit
This commit is contained in:
parent
cedc5b828a
commit
3785c9e221
2 changed files with 8 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
$string['accessexception'] = 'Access control exception';
|
||||
$string['activatehttps'] = 'connect with HTTPS to see the token';
|
||||
$string['activatehttps'] = '******************';
|
||||
$string['addfunction'] = 'Add function';
|
||||
$string['addfunctionhelp'] = 'Select the function to add to the service.';
|
||||
$string['addrequiredcapability'] = 'Assign/Unassign the required capability';
|
||||
|
@ -10,6 +10,7 @@ $string['actwebserviceshhdr'] = 'Active web service protocols';
|
|||
$string['apiexplorer'] = 'API explorer';
|
||||
$string['apiexplorernotavalaible'] = 'API explorer not available yet.';
|
||||
$string['arguments'] = 'Arguments';
|
||||
$string['authmethod'] = 'Authentication method';
|
||||
$string['configwebserviceplugins'] = 'For security reasons enable only protocols that are used.';
|
||||
$string['context'] = 'Context';
|
||||
$string['createtoken'] = 'Create token';
|
||||
|
@ -31,6 +32,9 @@ $string['function'] = 'Function';
|
|||
$string['functions'] = 'Functions';
|
||||
$string['generalstructure'] = 'General structure';
|
||||
$string['httpswarning'] = 'Token strings are only displayed if your connection is secured (https)';
|
||||
$string['invalidiptoken'] = 'Invalid token - your IP is not supported';
|
||||
$string['invalidtimedtoken'] = 'Invalid token - token expired';
|
||||
$string['invalidtoken'] = 'Invalid token - token not found';
|
||||
$string['iprestriction'] = 'IP restriction';
|
||||
$string['manageprotocols'] = 'Manage protocols';
|
||||
$string['managetokens'] = 'Manage tokens';
|
||||
|
|
|
@ -157,15 +157,15 @@ abstract class webservice_server implements webservice_server_interface {
|
|||
} else {
|
||||
if (!$token = $DB->get_record('external_tokens', array('token'=>$this->token, 'tokentype'=>EXTERNAL_TOKEN_PERMANENT))) {
|
||||
// TODO: MDL-12886 log failed login attempts
|
||||
throw new webservice_access_exception('Invalid token');
|
||||
throw new webservice_access_exception(get_string('invalidtoken', 'webservice'));
|
||||
}
|
||||
|
||||
if ($token->validuntil and $token->validuntil < time()) {
|
||||
throw new webservice_access_exception('Invalid token');
|
||||
throw new webservice_access_exception(get_string('invalidtimedtoken', 'webservice'));
|
||||
}
|
||||
|
||||
if ($token->iprestriction and !address_in_subnet(getremoteaddr(), $token->iprestriction)) {
|
||||
throw new webservice_access_exception('Invalid token');
|
||||
throw new webservice_access_exception(get_string('invalidiptoken', 'webservice'));
|
||||
}
|
||||
|
||||
$this->restricted_context = get_context_instance_by_id($token->contextid);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue