Category : jwt

I have implemented JWT token authentication with the help of this https://www.avyatech.com/rest-api-with-laravel-8-using-jwt-token/ Step 11. Prepare api controller actions -> authenticate() now, the system admin allows a user record to Mark as active/Inactive(status) and that inactive the User should not be able to log in into System Login logic: public function authenticate(UserRequest $request) { $credentials = ..

Read more

I try to combine JWT custom UserProvider. Users are store in external DB, accessed with API. config/auth.php ‘defaults’ => [ ‘guard’ => ‘api’, ‘passwords’ => ‘users’, ], ‘guards’ => [ ‘web’ => [ ‘driver’ => ‘jwt’, ‘provider’ => ‘shopAPI’, ], ‘api’ => [ ‘driver’ => ‘jwt’, ‘provider’ => ‘shopAPI’, ], ], ‘providers’ => [ ‘shopAPI’ ..

Read more

I need session to create cart for shopping but after store session in method when can I use On the same controller but another method can not access session data I try to add ‘StartSession’ ‘Middleware’ on ‘Kernel.php’ but not working IlluminateSessionMiddlewareStartSession::class, I use api route and for authentication use tymondesigns/jwt-auth package Sourc..

Read more

I have created an authentication with JWT in custom table. Authentication works fine, i am able to login and token is generated with success. The problem is not being able to get the information like ‘id’ etc FROM the generated TOKEN of the custom table. $token = $request->header(‘Authorization’); $user = JWTAuth::toUser($token); return $user; Returned information ..

Read more

axios .post( "http://127.0.0.1:8000/api/database", { // ğ:? , a: this.a, b: this.b, c: this.c, d: this.d, e: this.e, f: "trial", g: this.g, }, { headers: { Authorization: `Bearer ${localStorage.getItem("token")}`, }, } ) .then(function (response) { if (response) { swal( "Sipariş Başarıyla Oluşturuldu", "Ürün Sepete Eklendi", "success" ); } else { swal( "Sipariş Başarıyla Oluşturuldu", "Ürün Sepete ..

Read more

I’m trying to extend token expiration before it ends on certain conditions. I’m using the payload to get the current expiration. $payload = JWTAuth::parseToken()->getPayload(); $expires_at = date(‘Y-m-d H:i:s’, $payload->get(‘exp’)); How can I extend this ‘exp’ without changing the token. Sourc..

Read more

I’m using PHPUnit for testing my Laravel project. ?php namespace TestsFeature; use AppModelsUser; use TestsTestCase; class LoginTest extends TestCase { public function test_user_can_login(): { $user = User::factory()->create(); $response = $this->postJson(‘/api/auth/login’, [ ’email’ => $user->email, ‘password’ => $user->password, ]); $response ->assertStatus(200) ->assertHeader(‘Authorization’) ->assertJson([ ‘success’ => ‘Usuário logado com sucesso!’, ]); } } I want to create ..

Read more

"require": { "php": "^7.3|^8.0", "fideloper/proxy": "^4.4", "fruitcake/laravel-cors": "^2.0", "guzzlehttp/guzzle": "^7.0.1", "intervention/image": "^2.5", "laravel/framework": "^8.12", "laravel/tinker": "^2.5", "laravel/ui": "^3.2", "tymon/jwt-auth": "^1.0" }, this is my composer.json. now I need to add laravel/passport but it is giving some errors because of version conflicts with Tymon/jwt-auth. Laravel version:- v8.53.1 laravel/passport version: v10.1.3 composer require laravel/passport Using version ^10.1 ..

Read more