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