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

ArrayDataProvider with CGridView pagination Yii2
Yii framework 2.0 pass parameter to eager loading relational database table
Which folder to add custom helper functions to in Yii
Yii2: Assigning javascript event to anchor tag in yii2
Hide Yii2 GridView Action buttons
Yii2 query condition with exists
Retrieving array of Controllers/Actions
How to change label text of the ActiveField?
download files using Yii2 gridFS
Yii2:Does login,signup & password reset forms work together in single view
Yii2: How to add textarea in yii2
how to call login page partially on index page in yii2
Execute my code before any action of any controller
Twitter Bootstrap integration in yii2
How to publish an asset within a widget in Yii2
Yii2: Method not allowed arror while logout action from different controller

Categories

HOME
winforms
multithreading
osgi
netbeans
kde
framework7
cakephp-2.5
jxls
alpha
mouse
maude-system
kibana-4
tomcat6
modelica
collectd
jplayer
vb.net-2010
phaser
event-handling
carthage
seaborn
evopdf
sms-gateway
plunker
amazonsellercentral
autocad-plugin
paging
cx-freeze
microsoft-sync-framework
chromebook
uninstall
fluentvalidation
assistant
replaceall
gsoap
fog
phpfreechat
google-api-nodejs-client
suricata
file-format
occlusion
objectlistview
sharefile
spring-security-kerberos
user-accounts
upstart
logparser
boost-multi-index
jlink
sage-one
git-diff
tactic
android-cursor
pillow
smart-table
parallel-data-warehouse
color-picker
infix-notation
url-masking
mongocsharpdriver
angstrom-linux
essence
independentsoft
natvis
pervasive-sql
srand
maven-tomcat-plugin
t4mvc
marching-cubes
jmeter-maven-plugin
django-unittest
browser-bugs
c3
jscript.net
elliptic-curve
phpthumb
valuechangelistener
undefined-reference
html5-notifications
oam
quantlib-swig
blending
eventual-consistency
comaddin
eventlistener
selected
chrono
doh
external-accessory
vdsp
xdomainrequest
yetanotherforum
propagation
locate
gdlib
dentrix
getresponsestream
filtered-index
aquaticprime

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App