|
|
|
@ -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); |
|
|
|
|
|
|
|
|
|