1
总之,我收到以下错误:流明:JWT认证以无用户表
{
"message": "Undefined index: password",
"status_code": 500
}
一个liitle背景:
我有一个users
表,一个pincodes
表, users
表有两列mobile_number
和status
,我发送短信给用户表中的手机号码,短信有一个密码,然后我保存该代码以及user_id
pincodes
表。
因此,身份验证将适用于pincodes
,其中我有user_id
和code
来验证用户是否真实。我正在使用流明微框架,使用JWT认证library。所以我改变了我的Pincode
模型像User
模型一样。
namespace App;
use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable;
class Pincode extends Model implements
AuthenticatableContract,
AuthorizableContract {
use Authenticatable, Authorizable;
protected $table = 'pincodes';
public function user() {
return $this->belongsTo('App\User');
}
}
的验证方法的请求类型是后(如下所示),而且是PARAMS user_id
,和code
。我提供正确的。
和验证方法,其中令牌应该产生:
public function verify(Request $request) {
$uid = $request->get('uid');
$pinCode = $request->get('code');
$findPinCode = \App\Pincode::where('uid', $uid)->where('code', $pinCode)->first();
if (!$findPinCode) {
return response()->json([
'message' => 'No pin Code found',
'code' => 404,
]);
}
$findPinCode->status = 'v';
$findPinCode->dateVerify = Carbon::now();
$findPinCode->save();
try {
$this->validatePostLoginRequest($request);
} catch (HttpResponseException $e) {
return $this->onBadRequest();
}
try {
if (!$token = JWTAuth::attempt(
$this->getCredentials($request)
)) {
return 'asdasd';
return $this->onUnauthorized();
}
} catch (JWTException $e) {
return $this->onJwtGenerationError();
}
我收到以下错误:
{
"message": "Undefined index: password",
"status_code": 500
}