DELETE_PREVIOUS_ACCESS_TOKENS_ON_LOGIN and DEFAULT_ROLE_ID Environment Setting

pull/3/head
Hasin Hayder 3 years ago
parent 02a7b7fe10
commit 42ca6a382a

@ -52,3 +52,6 @@ MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
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
DELETE_PREVIOUS_ACCESS_TOKENS_ON_LOGIN=false

@ -2,7 +2,6 @@
namespace App\Http\Controllers;
use App\Models\Option;
use App\Models\Role;
use App\Models\User;
use Illuminate\Validation\ValidationException;
@ -55,7 +54,7 @@ class UserController extends Controller {
'name' => $creds['name']
]);
$default_user_role_id = Option::where('key', 'default_role_id')->first()->value;
$default_user_role_id = env('DEFAULT_ROLE_ID', 2);
UserRole::create([
'user_id' => $user->id,
'role_id' => $default_user_role_id
@ -82,7 +81,7 @@ class UserController extends Controller {
return response(['error' => 1, 'message' => 'invalid credentials'], 401);
}
if (Option::where('key', 'single_session')->first()->value == '1') {
if (env('DELETE_PREVIOUS_ACCESS_TOKENS_ON_LOGIN', false) == true) {
$user->tokens()->delete();
}

Loading…
Cancel
Save