yii2


Yii2 api username password validation


I am trying to validate a username and password to return access_token for the particular user, and I'm trying with this:
public $modelClass = 'app\models\User';
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = [
'class' => CompositeAuth::className(),
'authMethods' => [
[
'class' => HttpBasicAuth::className(),
'auth' => function($username, $password)
{
$out = null;
$user = \app\models\User::findByUsername($username);
if($user!=null)
{
if($user->validatePassword($password)) $out = $user;
}
return $out;
}
],
[ 'class' => QueryParamAuth::className(), ]
]
];
$behaviors['verbs'] = [
'class' => \yii\filters\VerbFilter::className(),
'actions' => [
'index' => ['get'],
],
];
return $behaviors;
}
but its giving me all the user list. How can I fix this?

Related Links

In YII2 validation rules I need something opposite to compare
How to add sendgrid mailer function in yii2?
Yii2 dataprovider- exclude first 2 elements
Many to many relationships in Yii2
yii2 swiftmailer link does not work
Call to a member function saveAs() on null (I can not update if I do not select an image)
yii2 dataProvider- offset in dataprovider doesn't work [duplicate]
Yii2 Active Record get the latest record
how to show json formated data in GridView
How to convert HTML page to image in yii2
Does Yii2 take care of the important security concerns?
Swift_IoException Unable to open file for reading yii2
Yii2 change the theming for just one view file
Trying to get property of non-object in action column in yii2
Default main.php config file for all projects in Yii2
Yii2 unit testing :: Access denied for user 'something'#'localhost' (using password: NO)

Categories

HOME
bluetooth
kde
google-api-php-client
paw-app
rdf
baqend
windows-server
serverspec
azure-media-services
indesign
session-variables
tomcat6
dax
collectd
google-cloud-spanner
after-effects
jsdoc
blazemeter
trading
smb
javacv
django-storage
phpfox
saas
bluestacks
media-queries
xquery-3.0
uisplitview
fog
openoffice.org
geopositioning
language-concepts
fusionpbx
trim
texmaker
reactive-cocoa-5
angular-resource
menuitem
flickr-api
taffy
filepicker
dds
promela
sybase-asa
capacity
hittest
bind9
webdriverjs
spring-android
sigabrt
actionbardrawertoggle
hover-over
sdf
ptrace
xpath-1.0
uid
javax.sound.midi
sframe
drawbitmap
ios9.1
javax.mail
offloading
jscript.net
client-side-templating
openexr
elliptic-curve
app42
html5-notifications
prettify
flexmojos
mysqltuner
quantlib-swig
html4
dataadapter
jquery-mobile-dialog
ember-app-kit
cassini-dev
robotics-studio
itmstransporter
pvrtc
gil
mt
nsnetservice
dsn
newtonscript
objective-c-2.0
qtkit
windows-phone-7.1.1
postgresql-performance
external-accessory
coercion
table-footer
oncheckedchanged
mongomapper
jmock
cxxtest
yslow
subviews
vc90
zend-tool
iweb
text-coloring
sector
ugc

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App