Loading diyip takilmasi muhtemelen baska bir sorundan kaynakli.
Route kodunu ve postman request'ini de eklermisin?
Postman ile şimdi response 200 dönüyor ama bir veri gözükmüyor.
/login kısmından token dönüşü oluyor.
routes.php
<?php
use SlimApp;
use SlimHttpRequest;
use SlimHttpResponse;
use FirebaseJWTJWT;
return function (App $app) {
$app->post('/login', function (Request $request, Response $response, array $args) {
$input = $request->getParsedBody();
$sql = "SELECT * FROM users WHERE email= :email";
$sth = $this->db->prepare($sql);
$sth->bindParam("email", $input['email']);
$sth->execute();
$user = $sth->fetchObject();
// verify email address.
if(!$user) {
return $this->response->withJson(['error' => true, 'message' => 'These credentials do not match our records.']);
}
// verify password.
if (!password_verify($input['password'],$user->password)) {
return $this->response->withJson(['error' => true, 'message' => 'These credentials do not match our records.']);
}
$settings = $this->get('settings'); // get settings array.
$token = JWT::encode(['id' => $user->id, 'email' => $user->email], $settings['jwt']['secret'], "HS256");
return $this->response->withJson(['token' => $token]);
});
$app->group('/api', function(SlimApp $app) {
$app->get('/user',function(Request $request, Response $response, array $args) {
print_r($request->getAttribute('decoded_token_data'));
/*output
stdClass Object
(
[id] => 2
[email] => arjunphp@gmail.com
)
*/
});
});
};Postman ekran görüntüsü