Browse Source

hierarcy

pull/3/head
farhantock 1 year ago
parent
commit
aae342f731
  1. 5
      app/Http/Controllers/AuthController.php

5
app/Http/Controllers/AuthController.php

@ -11,6 +11,7 @@ use App\Models\Role;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
class AuthController extends Controller
{
public function __construct()
@ -56,10 +57,14 @@ class AuthController extends Controller
}
$dataRole = Role::find($user->role_id);
$dataHierarchy = $this->getDataHierarchy($user->divisi_id, $user->id);
if ($dataRole)
$user->role = $dataRole;
if ($dataHierarchy)
$user->hierarchy = $dataHierarchy;
if (!$token = Auth::login($user))
return response()->json(['error' => 'Unauthorized'], 401);

Loading…
Cancel
Save