سلام استاد، وقتتون بخیر
ببخشید یه سوال داشتم
بنده طبق آموزش و داکیومنت jwt/auth که پیش رفتم، وقتی خواستم برای اولین بار، توکن را با ارسال email/pass به login دریافت کنم، همون ابتدا به بنده Unauthorized رو به عنوان response میده!
-> در ضمن داخل فایل AuthController هم که محتوایی که گفته بود رو قرار دادم، در متدهای زیر، متدهای attempt, logout, refresh, factory ارور Undefined میدن
علت این دو چی هستش؟
public function login()
{
$credentials = request(['email', 'password']);
if (!$token = auth('api')->attempt($credentials)) {
return response()->json(['error' => 'Unauthorized'], 401);
}
return $this->respondWithToken($token);
}
public function logout()
{
auth('api')->logout();
return response()->json(['message' => 'Successfully logged out']);
}
public function refresh()
{
return $this->respondWithToken(auth('api')->refresh());
}
protected function respondWithToken($token)
{
return response()->json([
'access_token' => $token,
'token_type' => 'bearer',
'expires_in' => auth('api')->factory()->getTTL() * 60
]);
}