要するに、私は次のエラーを受け取りますルーメン:JWT認証なしのユーザーテーブルと
{
"message": "Undefined index: password",
"status_code": 500
}
liitle背景:私はusers
テーブルを持っている
、そしてpincodes
テーブル、 users
テーブルには2つのカラムmobile_number
とstatus
があり、私はusersテーブルのモバイル番号にSMSを送信しています.SMSは秘密コードを持っていますので、user_id
pincodes
テーブル。
認証がpincodes
に適用されます。ここでは、user_id
とcode
があり、ユーザーが本物かどうかを確認できます。私はJWT認証libraryでルーメンマイクロフレームワークを使用しています。そこでUser
モデルのようにPincode
モデルを変更しました。
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
}