From 91aba8fdec9424ab49bb431a4d99dbee3303d77d Mon Sep 17 00:00:00 2001 From: Al-Amin Firdows Date: Mon, 30 May 2022 11:11:32 +0600 Subject: [PATCH 1/3] feat: add hydra config file --- config/hydra.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 config/hydra.php diff --git a/config/hydra.php b/config/hydra.php new file mode 100644 index 0000000..d8856f3 --- /dev/null +++ b/config/hydra.php @@ -0,0 +1,28 @@ + env('DEFAULT_USER_ROLE_ID', 1), + + /* + |-------------------------------------------------------------------------- + | Delete old access tokens when logged in + |-------------------------------------------------------------------------- + | + | This value determines whether or not to delete old access tokens when + | the users are logged in. + | + */ + + 'delete_previous_access_tokens_on_login' => env('DELETE_PREVIOUS_ACCESS_TOKENS_ON_LOGIN', false), +]; From 3c869ff00caa1dca8cde79b9d72937168fbcd63d Mon Sep 17 00:00:00 2001 From: Al-Amin Firdows Date: Mon, 30 May 2022 11:12:22 +0600 Subject: [PATCH 2/3] fix: update default user role id key on env file --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index c980f21..3e001c0 100644 --- a/.env.example +++ b/.env.example @@ -53,5 +53,5 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" SANCTUM_STATEFUL_DOMAINS="localhost,localhost:3000,localhost:8000,127.0.0.1,127.0.0.1:8000,::1" -DEFAULT_ROLE_ID=2 +DEFAULT_USER_ROLE_ID=2 DELETE_PREVIOUS_ACCESS_TOKENS_ON_LOGIN=false From 4cf5c9671e733f309c616105cbae1925f1151c4a Mon Sep 17 00:00:00 2001 From: Al-Amin Firdows Date: Mon, 30 May 2022 11:25:55 +0600 Subject: [PATCH 3/3] feat: replace env method call by config (Resolve #11) --- app/Http/Controllers/UserController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 4f0a1c0..bff84bf 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -45,10 +45,9 @@ class UserController extends Controller { 'name' => $creds['name'] ]); - $default_user_role_id = env('DEFAULT_ROLE_ID', 2); UserRole::create([ 'user_id' => $user->id, - 'role_id' => $default_user_role_id + 'role_id' => config('hydra.default_user_role_id', 2) ]); @@ -72,7 +71,7 @@ class UserController extends Controller { return response(['error' => 1, 'message' => 'invalid credentials'], 401); } - if (env('DELETE_PREVIOUS_ACCESS_TOKENS_ON_LOGIN', false) == true) { + if (config('hydra.delete_previous_access_tokens_on_login', false)) { $user->tokens()->delete(); }