Answer the question
In order to leave comments, you need to log in
YII2 - HttpBearerAuth. Why does it throw an error without specifying the optional property?
I do authentication through HttpBearerAuth on YII2.
If I specify WITHOUT 'optional' - throws an error. Your request was made with invalid credentials.
public function behaviors()
{
return [
'authenticator' => [
'class' => HttpBearerAuth::className(),
],
public function behaviors()
{
return [
'authenticator' => [
'class' => HttpBearerAuth::className(),
'optional' => ['*'],
],
/**
* @var array list of action IDs that this filter will be applied to, but auth failure will not lead to error.
* It may be used for actions, that are allowed for public, but return some additional data for authenticated users.
* Defaults to empty, meaning authentication is not optional for any action.
* Since version 2.0.10 action IDs can be specified as wildcards, e.g. `site/*`.
* @see isOptional()
* @since 2.0.7
*/
public $optional = [];
Answer the question
In order to leave comments, you need to log in
because the default value is an empty array, not all actions. in the piece you cited, it says that by default the list is empty, which means that authorization is NOT optional for any action (if verbatim). If in Russian, then it is mandatory for everyone
var el = 'rate-55345'
var numEl = parseInt(el.match(/\d+/))
alert(numEl)
var el = 'rate-5356';
// numEl изначально строка, чтобы числа не складывались друг с другом, а приписывались
var numEl = '';
// Перебираем каждый символ. Если символ можно распарсить как номер, приписываем к строке
for (var index in el) {
if ( parseInt(el[index]) ) {
numEl += el[index]
}
}
parseInt(numEl); // 5356
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question