Merge pull request #12 from alaminfirdows/feat/config

feat: use config function instead of using env directly
pull/13/head
Hasin Hayder 3 years ago committed by GitHub
commit 26d1bea70c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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" 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 DELETE_PREVIOUS_ACCESS_TOKENS_ON_LOGIN=false

@ -45,10 +45,9 @@ class UserController extends Controller {
'name' => $creds['name'] 'name' => $creds['name']
]); ]);
$default_user_role_id = env('DEFAULT_ROLE_ID', 2);
UserRole::create([ UserRole::create([
'user_id' => $user->id, '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); 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(); $user->tokens()->delete();
} }

@ -0,0 +1,28 @@
<?php
return [
/*
|--------------------------------------------------------------------------
| Default user role
|--------------------------------------------------------------------------
|
| This value is the default user role id that will be assigned to new users
| when they register.
|
*/
'default_user_role_id' => 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),
];
Loading…
Cancel
Save